Next.js Discord

Discord Forum

How i can use multiples layouts

Answered
Barbary Lion posted this in #help-forum
Open in Discord
Avatar
Barbary LionOP
Im wanna building a different layout for login page, but im receive a message error: Hydration failed because the initial UI does not match what was rendered on the server.
Answered by B33fb0n3
you can create multiple root layouts [by doing this](https://nextjs.org/docs/app/building-your-application/routing/route-groups#creating-multiple-root-layouts):
(see attached - or click link).
And then add inside each layout your own layouts:
export default function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return (
    <html lang="en">
      <body>
        {/* Layout UI */}
        <main>{children}</main>
      </body>
    </html>
  )
}
Image
View full answer

7 Replies

Avatar
you can create multiple root layouts [by doing this](https://nextjs.org/docs/app/building-your-application/routing/route-groups#creating-multiple-root-layouts):
(see attached - or click link).
And then add inside each layout your own layouts:
export default function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return (
    <html lang="en">
      <body>
        {/* Layout UI */}
        <main>{children}</main>
      </body>
    </html>
  )
}
Image
Answer
Avatar
Can you send your code also?
Avatar
Barbary LionOP
Now I can't, I'm not at home, but later I will send the structure of my project and also the code
Avatar
Barbary LionOP
In this case, I would like to have the /login/cliente route and the /login/admin route
Image
Avatar
Barbary LionOP
Thanks for your help guys, I managed to solve the problem
Avatar