Files
homaroma/apps/website/src/components/ScrollToTop.tsx
T

17 lines
350 B
TypeScript

"use client";
import { useEffect } from 'react'
import { usePathname } from 'next/navigation'
/**
* Scrolls window to top on every route change (Next.js version).
*/
export default function ScrollToTop() {
const pathname = usePathname()
useEffect(() => {
window.scrollTo({ top: 0, behavior: 'instant' })
}, [pathname])
return null
}