11 - Adding NgRx to Nx App
In this section we will add and discuss the default addition of NgRx to root and feature modules.
1. Add NgRx to Customer Portal App
nx g @nrwl/angular:ngrx --module=apps/customer-portal/src/app/app.module.ts --minimal true
? What name would you like to use for the NgRx feature state? An example would be "users". products
? Is this the root state of the application? Yes
? Would you like to use a Facade with your NgRx state? No
✔ Packages installed successfully.
UPDATE apps/customer-portal/src/app/app.module.ts
UPDATE package.jsonimports: [
BrowserModule,
BrowserAnimationsModule,
NxModule.forRoot(),
RouterModule.forRoot(
/// abbreviated
),
AuthModule,
LayoutModule,
StoreModule.forRoot(
{},
{
metaReducers: !environment.production ? [] : [],
runtimeChecks: {
strictActionImmutability: true,
strictStateImmutability: true,
},
}
),
EffectsModule.forRoot([]),
!environment.production ? StoreDevtoolsModule.instrument() : [],
StoreRouterConnectingModule.forRoot(),
],2. Add NgRx Auth lib making it a state state

Last updated