Open cjmling opened 2 months ago
Add scroll={false} to
Listen to path change and scroll to Top . Add this code to the component where it get included on every page.
const pathname = usePathname(); const searchParams = useSearchParams(); const scrollToTop = () => { window.scrollTo({ top: 0, behavior: "smooth", }); }; useEffect(() => { const url = `${pathname}?${searchParams}`; console.log("url", url); // You can now use the current URL // ... scrollToTop(); }, [pathname, searchParams]);
Add scroll={false} to
Listen to path change and scroll to Top . Add this code to the component where it get included on every page.