Standalone APIs with NgRx and Angular 15
Standalone APIs were added to version 15 of NgRx, allowing for easier usage of NgRx with Standalone Components in Angular.
They must be added to routes definitions as they need to be added to the Environment Injector (https://ngrx.io/api/store/provideStore).
Nx will use these Standalone APIs when:
- Standalone APIs are supported
- Angular 15 is installed
This guide will show you how to leverage this using the NgRx generator.
PrerequisitesBefore following along with this guide, ensure you have:
- An Nx >= 15.6.0 Workspace with
@nrwl/angular
installed - Angular 15 must be installed
Steps
- Generate an Angular application with Standalone Components and routing
nx g @nrwl/angular:app testapp --standalone --routing
- Generate NgRx Root State
nx g @nrwl/angular:ngrx --root --parent=testapp/src/main.ts
- Generate NgRx Feature State
nx g @nrwl/angular:ngrx users --parent=testapp/src/app/app.routes.ts