Customizing the _app.js and _document.js Pages
Learn to customize page initialization and HTML tags and to extend the Document class with custom scripts.
We'll cover the following
There are certain cases where we need to take control over page initialization so that every time we render a page, Next.js will need to run certain operations before sending the resulting HTML to the client. To do that, the framework allows us to create two new files, called _app.js
and _document.js
, inside our pages/
directory.
The _app.js
page
By default, Next.js ships with the following pages/_app.js
file:
Get hands-on with 1200+ tech skills courses.