Next.js Discord

Discord Forum

404 Page in nested routes

Answered
Bordin posted this in #help-forum
Open in Discord
Hello, I am facing trouble with nested routes. when going from /Dashboard to /Dashboard/Categories the page renders and works fine but when I refreshed the page, I got a 404 error page not found.
Answered by Ray
make sure you have a default.tsx for all the slot, otherwise it will throw 404 when the url is not match
View full answer

12 Replies

@Ray hey man, i apologize for the ping but I am desperate x.x
It's been 13 hours and i still couldn't figure out how to solve this issue. I can't find any useful information online
@Bordin Click to see attachment
make sure you have a default.tsx for all the slot, otherwise it will throw 404 when the url is not match
Answer
read the doc
nested
//dashboard/layout.tsx
"use client";
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import "../scss/DashboardPage.scss";
import "../scss/TopBar.scss";
import "../scss/Dashboards.scss";
import Provider from "./provider";
import "../scss/ViewItems.scss";

import { useRouter } from "next/router";
const inter = Inter({ subsets: ["latin"] });
export default function RootLayout({
  children,
  TopBar,
  Dashboard,
}: Readonly<{
  children: React.ReactNode;
  CategoryDashboard: React.ReactNode;
  Dashboard: React.ReactNode;
  TopBar: React.ReactNode;
  AddItem: React.ReactNode;
  ViewItems: React.ReactNode;
}>) {
  return (
    <Provider>
      <div style={{ display: "flex" }}>
        {Dashboard}
        <div id="RightSideDashboard">
          {TopBar}
          <div>{children}</div>
        </div>
      </div>
    </Provider>
  );
}
nvm you were right
@dashboard needed a default.tsx, not additem/viewitem
thank you once again ray! you are a saviour
@Bordin <@743561772069421169> hey man, i apologize for the ping but I am desperate x.x It's been 13 hours and i still couldn't figure out how to solve this issue. I can't find any useful information online
Asian black bear
Even if Ray has helped you out this time, don't ping others randomly. It's strictly against our rules.