concept router state in category angular

appears as: router state, router state, The router state
Angular Development with Typescript, Second Edition

This is an excerpt from Manning's book Angular Development with Typescript, Second Edition.

The name of the router state within the store is defined by the property name (for example, router) mapped to the router reducer. In your app, you’ll use the default routerReducer and add it to the collection of app reducers:

StoreModule.forRoot({...reducers, router: routerReducer}),

The value of the stateKey property is used to find the router state within the store and connect it to Redux DevTools, so that time traveling during debugging works. The value assigned to stateKey (the router, in your case) must match the property name used in the map of reducers provided to the forRoot() method. To access a particular property of the router state, you can use the ngrx select operator on the object represented by the router variable.

Accessing the entire router state may crash Redux DevTools, which is why we created a custom router state serializer to keep in the store only the state properties you need. In the shared/services/router-state-serializer.service.ts file, we’ve implemented a serializer that returns an object containing only url, params, and queryParams. If we didn’t implement this serializer, the router state shown in figure 15.14 would have lots of nested properties.

15.2.5. Monitoring the router state

When a user navigates an app, the router renders components, updates the URL, and passes parameters or query strings if need be. Behind the scenes, the router object represents the current state of the router, and the @ngrx/router-store package allows you to keep track of the router state in the ngrx store.

This package doesn’t change the behavior of Angular Router, and you can continue using the Router API in components, but because the store should be a single source of truth, you may want to consider representing the router state there as well. At any given time, the ngrx store can give you access to such route properties as url, params, queryParams, and many others.