Nextjs does not render styles on the server (client only) when used within a monorepo that has mixed versions of styled-jsx
See original GitHub issueWhat version of Next.js are you using?
12.0.7
What version of Node.js are you using?
14.18.1
What browser are you using?
chrome
What operating system are you using?
mac0s
How are you deploying your application?
vercel
Describe the Bug
styled-jsx
does not render styles server side when there are multiple versions of itself within a monorepo.
This is directly related to https://github.com/vercel/styled-jsx/issues/751. I am bringing it up here because I suspect there is something else going on besides node module resolution causing this bug – is it possible that the nextjs webpack config is grabbing the wrong version of styled-jsx
at compile time?
Video
Before: Styling works because JS is enabled. After: JS is disabled so styling does not work.
Expected Behavior
I expect the styling to be rendered on the server, not the client.
To Reproduce
- Clone @Regaddi’s repo: https://github.com/Regaddi/yarn-next-styled-jsx-fouc
- run
yarn install
- run
cd /packages/example/
yarn run dev
- In chrome, open dev tools and click the little cog icon at the top right.
- Disable Javascript and do not close the dev tools window.
- Refresh page.
- Observe no styles rendered.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Server-side rendered styled-components with Nextjs
js comes configured with styled-jsx . But what if you want to use something else for styling? I've recently worked on setting up...
Read more >Basic Features: ESLint - Next.js
Next.js provides an integrated ESLint experience by default. These conformance rules help you use Next.js in the optimal way.
Read more >Styles not applying on first client render (nor after) when ...
I would expect the server to send back the html/styles for the server based version of the component, and then following the first...
Read more >What's new in Next.js 13, and what do they really do?
A practical guide to Next.js 13. How real-world code and architecture need to adapt to Server Components, Streaming SSR, Layouts, and Turbopack.
Read more >Storybook Addon Next
A no config Storybook addon that makes Next.js features just work in ... If you feel that you have a good use case,...
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
Update:
It looks like webpack is doing its thing with styled-jsx and pulling it somehow. If you view
yarn-next-styled-jsx-fouc/node_modules/next/node_modules/styled-jsx/dist/webpack.js
in the example repo, you’ll seeSo it looks like webpack is doing some static stuff with styled-jsx and pulls in that depdendency via this pattern
(scoped|global|resolve)
. I don’t really know what’s going on here but it’s progress 🤷♂️This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.