export default defineNuxtPlugin((nuxtApp) => { let previousPath: string | null = null; let isFirstLoad = true; nuxtApp.hook("page:finish", () => { const { fullPath: currentPath } = useRoute(); if (isFirstLoad) { previousPath = currentPath; isFirstLoad = false; return; } if (previousPath !== currentPath) { window.scrollTo({ top: 0, behavior: "auto" }); previousPath = currentPath; } }); });