- Use npm to install the bindings:
npm install @ngrx/router-store --save
- Use the
routerReducer
when providingStore
:
import { provideStore } from '@ngrx/store';
import { routerReducer } from '@ngrx/router-store';
export const storeProvider = provideStore({
// Your reducers go here,
router: routerReducer
});
- Install the bindings providers after you setup the router providers:
import { connectRouterToStore } from '@ngrx/router-store';
bootstrap(App, [
storeProvider,
provideRouter(routes),
connectRouterToStore()
]);