Awesome Open Source
Awesome Open Source

This repository is for version 1.x of of @ngrx/router-store.

Click here for the latest version (4.x)


Bindings to connect angular/router to ngrx/store

Join the chat at


npm install @ngrx/[email protected] --save


  1. Use the routerReducer when providing the StoreModule.provideStore and add the RouterStoreModule.connectRouter to the @NgModule.imports:
import { StoreModule } from '@ngrx/store';
import { routerReducer, RouterStoreModule } from '@ngrx/router-store';

  imports: [
    StoreModule.provideStore({ router: routerReducer }),
  bootstrap: [ AppComponent ]
export class AppModule {
  1. Add RouterState to main application state:
import { RouterState } from '@ngrx/router-store';

export interface AppState {
  router: RouterState;
  1. (Optional) Set the initial value for the router state:
StoreModule.provideStore({ router: routerReducer }, {
  router: {
    path: window.location.pathname +

Dispatching Actions

import { go, replace, search, show, back, forward } from '@ngrx/router-store';

Navigation with a new state into history

store.dispatch(go(['/path', { routeParam: 1 }], { query: 'string' }));

Navigation with replacing the current state in history

store.dispatch(replace(['/path'], { query: 'string' }));

Navigation without pushing a new state into history

store.dispatch(show(['/path'], { query: 'string' }));

Navigation with only changing query parameters

store.dispatch(search({ query: 'string' }));

Navigating back


Navigating forward


Navigation Extras

The Angular Router Navigation Extras are supported with each router action.

import { NavigationExtras } from '@angular/router';

let extras: NavigationExtras = {
  relativeTo: ActivatedRoute,
  fragment: string,
  preserveQueryParams: boolean,
  preserveFragment: boolean,
  skipLocationChange: boolean,
  replaceUrl: boolean

store.dispatch(go(['path', { routeParam: 1 }], { query: 'string' }, extras));

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
typescript (11,952
angular (1,321
router (304
rxjs (160
ngrx (63