Closed nkzawa closed 7 years ago
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
@nkzawa also, to clarify, I was thinking pages/_document.js
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.
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.
Commit: 0bcd1fc39bb07f67b94238a0e867e9c3fe73a163
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 replacenext/css
withkhan/aphrodite
like the following:Related: https://github.com/zeit/next.js/issues/247
cc @rauchg