#httpsbeta nextjs orgdocsroutingdefining

1 messages ยท Page 1 of 1 (latest)

tardy trellis
#

is this correct

#

as in the (withNav)/page.tsx is the index page

tardy trellis
raw mortar
#

how does the layout.tsx look like

tardy trellis
#
import Head from "../Head";

export default function RootLayout({
  // Layouts must accept a children prop.
  // This will be populated with nested layouts or pages
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html lang="en">
      <Head />
      <h1>This is a nav bar</h1>
      <body>{children}</body>
    </html>
  );
}
 ``` this is in the (withNav)/layout
raw mortar
#

remove app/layout.tsx

tardy trellis
#

do you know why this comes up?

#

it renders the items correctly

raw mortar
#

how you get the error?

tardy trellis
tardy trellis
tardy trellis
#

thats my page.tsx file ``` export default function Page() {
return <div className="text-red-500 text-2xl"> Dashbord </div>;
}

tardy trellis
raw mortar
#

yes

tardy trellis
#

even my navbar?

raw mortar
#

yea

#

navbar should be inside body tag anyway

tardy trellis
#

oh thank you! this helped so much ๐Ÿ™‚

tardy trellis
#

just a quick question whats the alternative of using group layouts with the normal page directory to get the same effect? as getting to many errors when trying the app directory ๐Ÿ˜ฆ

raw mortar
#

either put the navbar in every page or turn the layout to client component and only render the page except /login with usePathname hook

#

what do you mean by getting many errors?

tardy trellis
raw mortar
#

well those error not related to route group

tardy trellis
#

yeah I know but route grouping is not available without using the app dir right?

raw mortar
#

yeah

#

you can just create a normal Layout Component with pages directory