#migrate page router to app router.

16 messages · Page 1 of 1 (latest)

wide troutBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

south glen
#

the layout.jsx receives a props with children
the page.jsx receives a object of params and searchParams

#

there are also headers() and cookies() from next/navigation

#

what you want to do?

#

create app/layout.tsx first
then you could start migrating the page. page router and app router can use together

#

basically you don't need those props in layout

#

what do you use previousPathname for?

#

so just need to do this in layout.jsx

export default function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return (
    <html lang="en">
      <body>{children}</body>
    </html>
  )
}
#

what is the url ?

#

of the article

#

can you show a screenshot of your folder structure?

#

rename index.mdx to page.mdx

#

np

#

for the usePrevious, you could create a client component and render it in layout or other place

#

usePathname() hook can get the current path