Next.js: Warning `prop` className did not match. Server: "generated_server_className" Client: "generated_client_className"
See original GitHub issueDescribe the bug
After next.js compiles it throws a runtime error with something along the lines of:
Warning: Prop `className` did not match. Server: "pages_themeClass__sryalf0" Client: "pages__createTheme__sryalf0"
Link to reproduction
I have a fork of next.js that has an example of vanilla-extract with typescript and javascript
System Info
Output of npx envinfo --system --npmPackages @vanilla-extract/css,@vanilla-extract/webpack-plugin,@vanilla-extract/esbuild-plugin,@vanilla-extract/vite-plugin,@vanilla-extract/sprinkles,webpack,esbuild,vite --binaries --browsers
:
System:
OS: Linux 5.14 Arch Linux
CPU: (4) x64 AMD A8-7600 Radeon R7, 10 Compute Cores 4C+6G
Memory: 341.82 MB / 6.74 GB
Container: Yes
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.17.6 - ~/.local/share/volta/tools/image/node/14.17.6/bin/node
npm: 6.14.15 - ~/.local/share/volta/tools/image/node/14.17.6/bin/npm
Browsers:
Brave Browser: 93.1.29.81
npmPackages:
@vanilla-extract/css: ^1.6.0 => 1.6.0
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Warning: Prop `className` did not match. when using styled ...
That error is showing you the class that is being created by your styled-components library on the server and how it is different...
Read more >Warning: Prop className did not match. #7322 - GitHub
It appears to be an issue that backend generates styled component but client doesn't get it/doesn't use it and instead of using server...
Read more >Solving the Styled Components Warning in Next.JS with Babel
Warning : Prop `className` did not match. Server: “fs-fdsf” Client: “sd-dfasj”. The combination of Next.JS and Styled Components is truly ...
Read more >Fixing ClassName did not match error - DEV Community
Warning : Prop `className` did not match. Server: Client: Enter fullscreen mode ... Tagged with nextjs, typescript, styledcomponent, react.
Read more >Warning: Prop `className` did not match in Next.JS site with ...
By adding a unique identifier to every styled component, this plugin avoids checksum mismatches due to different class generation on the client and...
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 believe this is caused by differing Babel targets between the client and server builds which means that the vanilla-extract Babel plugin can’t consistently create debug IDs for you.
As a workaround, you can apply an explicit debug ID yourself:
This is now fixed in
@vanilla-extract/babel-plugin@1.1.1
.