router.scrollBehavior.js does not work

Using a router.scrollBehavior.js file does not seem to work. If I include my scroll behavior as a function in my config file, as an option of router, it works. If include it as a file as detailed in the documentation it does not work.

What’s more confusing is that in the example ( there is a router.js file and router.scrollBehavior.js is imported.

Is this a bug, or is the documentation incorrect?


  • nuxt: v2.14.12
  • node: v12.18.3

Steps to reproduce

Basic nuxt setup, create a router.scrollBehavior.js file

What is Expected?

Forcing the scroll position to the top for every route

What is actually happening?

Page does not scroll

1 possible answer(s) on “router.scrollBehavior.js does not work

  1. Ok, so the file needs to actually be in a folder named “app”. I would suggest changing the documentation as one can easily assume that “app” is a reference to my own nuxt app/template folder structure, and not necessarily an actual sub folder named “app”.