Skip to content

Next.js tips

David Lindkvist edited this page Mar 3, 2023 · 1 revision

Recommended usage with Next.js

export default function DefaultPageTransition({ children }) {
  const router = useRouter();

  // get a more friendly path name (especially for generic pages instead of [...slug])
  const pageName = router.asPath; 

  return (
    <PageTransitions
      key={router.isReady ? 'hydrated' : 'ssr'} // make sure ?querystring parsing works
      pageName={pageName}
    >
      {children}
    </PageTransitions>
  );
}
Clone this wiki locally