Next.js Discord

Discord Forum

(Beginner) When should I use _app.js ?

Answered
Pierre-Antoine posted this in #help-forum
Open in Discord
I am new to using nextjs, after doing the dashboard tutorial, the _app.js file is never used, I do not understand the difference with the layout.js file at the root of /app.
in which case to use a _app.js file? Thank you.
Answered by Rafael Almeida
the _app file is only used with the pages router, if you are using the app router it has no use. you can read more about it here: https://nextjs.org/docs/pages/building-your-application/routing/custom-app
View full answer

6 Replies

the _app file is only used with the pages router, if you are using the app router it has no use. you can read more about it here: https://nextjs.org/docs/pages/building-your-application/routing/custom-app
Answer
Also, if you're just starting out with Next.js focus on learning the new patterns that came along with the app router (Next.js v13 and above) and React 18 (so RSCs, Server Actions and co.)