Turning on ScrollTop Restoration for the Standalone Angular Router

Ole Ersoy
May 24, 2023


Image by Couleur from Pixabay


We want the Angular Router to always scroll back to the top of the viewport after navigation.


While bootstrapping the app component configure the router like this.

const scrollConfig: InMemoryScrollingOptions = {
scrollPositionRestoration: 'top',
anchorScrolling: 'enabled',

const inMemoryScrollingFeature: InMemoryScrollingFeature =
bootstrapApplication(App, {
providers: [provideRouter(routes, inMemoryScrollingFeature)],


This demo shows what happens without scroll position restoration. If you scroll to the bottom of view 1 and then navigate to view2, the viewport scroll position will remain at the bottom.