Reputation: 786
Could someone explain to me what is the difference between index.js file and _app.js? In the Next tutorial it says to change the index.js but what is rendered for me is _app.js.
Upvotes: 21
Views: 9972
Reputation: 1238
_app.js
will contain your whole app, meaning this will be rendered in any page of the project. Eg. if you add a <div>hello world</div>
in this file, you will see the Hello World on each and every page of your website. More reading here.
index.js
will only be rendered if you access /
path of your website. You will use index files whenever you create a new page, for example you want an about page, you will have an about folder containing an index.js
, all of this contained in the pages
folder. More reading here .
Upvotes: 40