import { Injectable } from '@angular/core' ; import { RouterStateSnapshot } from '@angular/router' ; import { RouterStateSerializer } from '@ngrx/router-store' ; import { RouterUrlState } from '../interfaces/router-url-state.interface' ; see https @ Injectable ( ) export class StoreRouterStateSerializer implements RouterStateSerializer < RouterUrlState > { param routerState serialize ( routerState ) { let route = routerState . root ; while ( route . firstChild ) { route = route . firstChild ; } const { url , root : { queryParams } } = routerState ; const { params } = route ; return { url , params , queryParams } ; } }