Home

Issue: 1664

import router from '~router' stopped working

[issue link]

Hello. I had a fix for scrolling to top behavior when page transition, but with latest Nuxt releases it stoped working. It was a plugin:

import router from '~router'

router.afterEach((to, from) => {
  setTimeout(() => {
    if (document) document.body.scrollTop = 0
  }, 515)
})

But now this import router from '~router' gives me an error.

Any tips how to fix it? How to access router with latest API?

This question is available on Nuxt.js community (#c1489)