Next.js Discord

Discord Forum

Dashboard group layout

Answered
vsw posted this in #help-forum
Open in Discord
Avatar
vswOP
How do I lose the navbar from my root layout in my dashboard group layout?
Answered by James4u
(landing)
(dashboard)
View full answer

8 Replies

Avatar
vswOP
root:

import type { Metadata } from "next";
import { Inter } from "next/font/google";
import "./globals.css";
import Navbar from "@/components/shared/navbar"; 
import { Toaster as Sonner } from "@/components/ui/sonner";

const inter = Inter({
  subsets: ["latin"],
  display: "swap",
});

export const metadata: Metadata = {
  title: "Next starter",
  description: "Next starter by Jake Mackie",
};

export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  return (
    <html lang="en" suppressHydrationWarning>
      <body className={`${inter.className} antialiased dark`}>
        <Navbar />
        {children}
        <Sonner />
      </body>
    </html>
  );
}


app/(dashboard)/layout.tsx

export default function DashboardLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  return <div>{children}</div>;
}
Image
Image
Avatar
Antillean Palm Swift
One way I can think of is remove the Navbar component from the root layout.

In the dashboard layout, you can introduce some other navbar depending on your needs.

And may be put this Navbar back in the other layouts other than the Root layout.
Avatar
(landing)
(dashboard)
Answer
Avatar
and you will have different layouts for them where you can use different header there