We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3ea47eb commit b748ae6Copy full SHA for b748ae6
app/router.options.ts
@@ -0,0 +1,18 @@
1
+import type { RouterConfig } from '@nuxt/schema'
2
+
3
+export default {
4
+ scrollBehavior(to, _from, savedPosition) {
5
+ // If the browser has a saved position (e.g. back/forward navigation), restore it
6
+ if (savedPosition) {
7
+ return savedPosition
8
+ }
9
10
+ // If navigating to a hash anchor, scroll to it
11
+ if (to.hash) {
12
+ return { el: to.hash, behavior: 'smooth' }
13
14
15
+ // Otherwise, scroll to the top of the page
16
+ return { left: 0, top: 0 }
17
+ },
18
+} satisfies RouterConfig
0 commit comments