createGlobalStyle does not work with next.js 7 when deployed to now
See original GitHub issueEnvironment
## System:
- OS: macOS 10.14.1
- CPU: x64 Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz
- Memory: 125.21 MB / 16.00 GB
- Shell: 3.2.57 - /bin/bash
## Binaries:
- Node: 10.6.0 - /usr/local/bin/node
- Yarn: 1.3.2 - /usr/local/bin/yarn
- npm: 6.1.0 - /usr/local/bin/npm
- Watchman: 4.9.0 - /usr/local/bin/watchman
## npmPackages:
- babel-plugin-styled-components: ^1.8.0 => 1.8.0
- styled-components: ^4.0.2 => 4.0.2
Reproduction
This appears to be a problem with deploying a project using next.js v7 + styled-components v4, when the createGlobalStyle
is used in the _document.js
file.
Steps to reproduce
- Clone https://github.com/specfm/spec-next/tree/sc-4
- Checkout
sc-4
branch - deploy with
now
Expected Behavior
The normalize.js
file which contains the createGlobalStyle
should be injected into the <head>
of the document to provide global css reset styles.
Actual Behavior
The createGlobalStyle
does not inject the global css into the <head>
when deployed with now
- about 1/10 of my deploys has it randomly work, but most deploys will look like this:
Expected design is at spec.fm - the deploy live right now had to be built with styled-components@3.x
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Server side rendering Styled-Components with NextJS - Medium
The basic idea is that when your app renders on the server, you can create a ServerStyleSheet and add a provider to your...
Read more >How do I use GlobalStyles from styled components in next?
You can use a custom app, by creating a _app.js file in pages directory import { createGlobalStyle } from 'styled-components' const ...
Read more >Releases - styled-components
Because styled-components allows any kind of prop to be used for styling (a trait shared by most CSS-in-JS libraries, but not the third...
Read more >Styled-components with Nextjs 12 - Reddit
It works now. I tried importing the GF into <createGlobalStyle /> from styled-components but in their doc they say that its not recommended....
Read more >Adding Fonts in Next.js (local fonts along with styled ...
js is only rendered on the server side and not on the client side. so event handlers like onClick is not going to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I also have this problem when using createGlobalStyle with nextjs v.7, and it happens only for the first request of built version of my project.(dev seems to be ok). I use express as a customized server for dynamic route of nextjs.
I believe global styles need to go in _app.js or individual pages.
On Mon, Oct 22, 2018, 1:32 AM Brian Lovin notifications@github.com wrote: