You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To override the default document rendering, define _document.js.
This will allow you to use any css modules and head manage components.
For example, you'd be able to replace next/css with khan/aphrodite like the following:
Reacted by Vlad Frolov, Guillermo Rauch, Tyler, Emily Eisenberg, Phil Cockfield, Yannik Schweinzer, David Jones, Jesse Koivukoski, Shawn Kelly, Brian Hurlow and 2 more
This will also allow to flawlessly include external dependencies required in #221. However, it may introduce some issues with Next.js upgrades as those who chose to override the Document will need to keep track of the changes done in the Next.js built-in Document implementation.
@frol yeah, I did think about the upgrade scenario. But at the end of the day, this is advanced behavior. Most people are not going to need to extend the core document
Totally! I second @jonaswindey point here. Even ignoring 3rd party CSS libs like bootstrap, avoiding the "white flash on load" when you have a dominant background color is important.
Activity
frol commentedon Nov 14, 2016
This will also allow to flawlessly include external dependencies required in #221. However, it may introduce some issues with Next.js upgrades as those who chose to override the Document will need to keep track of the changes done in the Next.js built-in Document implementation.
rauchg commentedon Nov 14, 2016
@frol yeah, I did think about the upgrade scenario. But at the end of the day, this is advanced behavior. Most people are not going to need to extend the core document
rauchg commentedon Nov 14, 2016
@nkzawa also, to clarify, I was thinking
pages/_document.jsjonaswindey commentedon Nov 16, 2016
Another reason to have a custom core document is if we want to add a className to the body tag, which is currently not possible.
A lot of bootstrap templates have classnames on this tag.
philcockfield commentedon Nov 16, 2016
Totally! I second @jonaswindey point here. Even ignoring 3rd party CSS libs like bootstrap, avoiding the "white flash on load" when you have a dominant background color is important.
ijjk commentedon Sep 30, 2019
Stats from current PR
Default Server Mode
General
Client Bundles (main, webpack, commons)
Client Bundles (main, webpack, commons) Modern
Client Pages
Client Pages Modern
Client Build Manifests
Rendered Page Sizes
Serverless Mode
General
Client Bundles (main, webpack, commons)
Client Bundles (main, webpack, commons) Modern
Client Pages
Client Pages Modern
Client Build Manifests
Serverless bundles
Commit: 0bcd1fc