···11+import type { RouterConfig } from '@nuxt/schema'
22+33+export default {
44+ scrollBehavior(to, _from, savedPosition) {
55+ // If the browser has a saved position (e.g. back/forward navigation), restore it
66+ if (savedPosition) {
77+ return savedPosition
88+ }
99+1010+ // If navigating to a hash anchor, scroll to it
1111+ if (to.hash) {
1212+ return { el: to.hash, behavior: 'smooth' }
1313+ }
1414+1515+ // Otherwise, scroll to the top of the page
1616+ return { left: 0, top: 0 }
1717+ },
1818+} satisfies RouterConfig