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
Hey in Nextjs 13 you will have
app directory
orsrc/app directory
to handle routing and create your application.Basic Introduction –
You might now have app/layout.js and app/page.js
Further if you want to create more routes example localhost:3000/login
app/login/page.js
app/register/page.js
For details/reference – https://nextjs.org/docs/app/building-your-application/upgrading/app-router-migration
@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)