skip to Main Content

I am beginner at NextJs and when I install next here is image attached using command "yarn create next-app" it create my app but problem is it does not have page directory what should I do now please help me…

I am trying to building NextJs app but in NextJs app Page directory is not available

2

Answers


  1. Hey in Nextjs 13 you will have app directory or src/app directory to handle routing and create your application.

    Basic Introduction –
    You might now have app/layout.js and app/page.js

    • Layout file is the default layout for all the pages you create
    • page.js is your main page

      Further if you want to create more routes example localhost:3000/login

    • Your folder structure will look something like
      app/login/page.js
    • Another example for /register i.e localhost:3000/register
      app/register/page.js
    page.js is the main entry point for any route
    

    For details/reference – https://nextjs.org/docs/app/building-your-application/upgrading/app-router-migration

    Login or Signup to reply.
  2. @Neeraj already answer your question but the pages directory is not the only change on the last version of NextJS, server side components are stable on this version… This last version need a new code structure and read new docs.

    If you are on a rush to create new project with existing knowledge about NextJS, you need to create a NextJS project with old versions (like 13.1.2 where App directory was experimental yet):
    npx [email protected] panda1 and inside panda1 folder: npm i [email protected]. This is because you can’t install specific version using npx, you need to override it with the old version install.

    Don’t forget to delete the caret (^) on the next dependency on package.json (to prevent accidental updates on version)

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