-
Notifications
You must be signed in to change notification settings - Fork 26.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global styles not being rendered server side and only occuring client side with flicker #5629
Comments
Just tried locally and it's working perfectly fine, as you can see below font-size: 50px; is in the initial response
|
Are you by any chance adding a custom _document.js? |
@timneutkens I am in fact using a custom _document.js as I'm using the styled-components template. Apologies, does this directly impact the usage of global styles? I would imagine now that this implies all of the global style code should go inside of _document.js? |
Basically yes, because that example uses https://github.com/zeit/next.js/blob/canary/packages/next/pages/_document.js#L18 |
- use `enhanceApp` so that styled-components used in _app.js are server rendered - call parent getInitialProps, fixes vercel#5629 - return `styles`, making the render() method obsolete.
- use `enhanceApp` so that styled-components used in _app.js are server rendered - call parent getInitialProps, fixes #5629 - return `styles`, making the render() method obsolete. cc @mxstbr @probablyup
@timneutkens Thanks for your time as always, Tim! |
Bug report
On Next 7.0.2, using the Global styles and layouts approach to get CSS onto the page (https://github.com/zeit/next.js/wiki/Global-styles-and-layouts), my CSS is not being added to my app on server render but occurs on the client side. I will then see a "flicker/flash" where my styles come in after the fact. I have tried uninstalling/reinstalling Next to no avail.
Below is an example of my code
Screenshots
Thanks a ton for any help.
The text was updated successfully, but these errors were encountered: