Next.js: Styles declared in _document not shown properly

Created on 14 Jun 2018  路  1Comment  路  Source: vercel/next.js

Bug report

Describe the bug

Global styles declared in _document.js doesnt get applied on first load after server restart.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Add some styles in _document, e.g <style jsx global{ * { margin: 0; } }</style>
  2. Start server (Im using a custom express server)
  3. Load the page (styles is not applied)
  4. Refresh page (styles are applied)

Expected behavior

Styles to be displayed on first load

Screenshots

https://imgur.com/a/RP3smAZ

System information

  • OS: *
  • Browser *
  • Version of Next.js: 6.0.3

Most helpful comment

You shouldn't use styled-jsx in _document.js. Instead use _app.js or use the <style> tag directly.

>All comments

You shouldn't use styled-jsx in _document.js. Instead use _app.js or use the <style> tag directly.

Was this page helpful?
0 / 5 - 0 ratings