skip to Main Content

I’m new with Next js, and I’m adding a new page, I just create a folder pages inside of src/app, then I add file dashboard.tsx but when I try to go to http://localhost:3000/dashboard I have this issue:

404 | This page could not be found.

why??

enter image description here

2

Answers


  1. The root file of a directory is index.tsx

    Edit

    As pointed out by another answer, you are using Next 13 and the app folder feature.

    The page you are aiming to create should be app/dashboard/index.tsx

    (not as previously mentioned pages/dashboard/index.tsx — which however would apply if you are pre-Next 13 or are opting out of the app folder)

    Login or Signup to reply.
  2. It seems you are using app directory feature of NextJS 13. To make http://localhost:3000/dashboard work the file structure should be

    app/dashboard/page.tsx

    dashboard = a folder
    page.tsx = file, the page content, basically what you have in dashboard.tsx put it in this file

    You can check for differences here https://blog.logrocket.com/next-js-13-app-directory/#page-directory-vs-app-directory

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search