EnvironmentProvider breaks SSR for Next.js
See original GitHub issue🐛 Bug report
After upgrading from @chakra-ui/react@1.5.0
to @chakra-ui/react@1.5.1
, the server side render in Next.js results in a single <span></span>
.
Likely point of introduction: https://github.com/chakra-ui/chakra-ui/commit/81a40231f12461dcca0fa0cd3c4e9e2c0497a04d
💥 Steps to reproduce
- Go to https://lyhzc.sse.codesandbox.io/
- Open dev tools and disable JS
- Refresh the page
- Observe that the DOM contains
<div id="__next"><span></span></div>
Alternatively
- http https://lyhzc.sse.codesandbox.io/ | tidy -xml
- Observe the same error
💻 Link to reproduction
CodeSandbox reproduction: https://codesandbox.io/s/infallible-bardeen-lyhzc?file=/pages/_app.js
🧐 Expected behavior
Server render should return the expected html content.
🧭 Possible Solution
Only just starting to dig into this, but it looks like the default environment needs to be more sophisticated can relying on canUseDOM()
.
Interestingly, providing any old string as the environment
seems to prevent the issue from occurring i.e.
<ChakraProvider environment="...">
<MyApp />
</ChakraProvider>
🌍 System information
Software | Version(s) |
---|---|
Chakra UI | 1.5.1 |
Browser | Chrome 89.0.4389.128 |
Operating System | macOS 10.15.6 |
📝 Additional information
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
react-hydration-error - Next.js
When css-in-js libraries are not set up for pre-rendering (SSR/SSG) it will often lead to a hydration mismatch. In general this means the...
Read more >What's New in Next.js 13 - AppSignal Blog
You can dig deeper and use React's Suspense to further break down the UI. You can make sure the layout renders while a...
Read more >Server-side rendering broken after upgrading to MUI 5 (with ...
I launched the official SSR Next.js implementation. It showed it doesn't work either. Server-side rendering with JavaScript disabled. For more ...
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 >NextJS / React SSR: 21 Universal Data Fetching Patterns ...
In NextJS, you can simply define an endpoint in the "/api" directory, which can then be called by using "swr" or just "fetch"....
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
Also just getting this now:
Will try and get a repro too
This has been fixed and we’re releasing an update shortly