router: Hydration mismatch errors in linked stylesheets.
Which project does this relate to?
Start
Describe the bug
After making a change that introduces an exception in the css loading, once you’ve corrected the error, you’ll get a persistent hydration mismatch until the vinxi server is restarted. This continues even after hard refreshes of the page.
Your Example Website or App
https://stackblitz.com/github/tanstack/router/tree/main/examples/react/start-basic
Steps to Reproduce the Bug or Issue
- Make a change in the css with an error, e.g.,
sahflsdjfhlssomewhere in the file. - See the error. HMR doesn’t seem to work on stackblitz, but you’ll see it locally immediately.
- Correct the error. The CSS is fixed, but you’ll have a hydration mismatch in the console.
Expected behavior
I expect to not have any error messages after correcting the CSS.
Screenshots or Videos
Platform
- OS: macOS
- Browser: Chrome and Firefox
Additional context
I noticed while recording the video that the error happened again after restarting Vinxi without making any erroneous edits to the CSS, just refreshing the page. 🤷♂
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 20
- Comments: 26 (2 by maintainers)
Also getting this error with a new
create-tsrouter-app. It happens with any change in the CSS, either instyles.cssor any JSX. Restarting the dev server somewhat fixes it, editingstyles.cssreintroduces it but editing JSX is fine. Package versions:1.114.34.0.12(upgraded from4.0.6)4.0.12(upgraded from4.0.6)4.0.12(upgraded from4.0.7)8.5.3(upgraded from8.5.2)I do have a
postcss.config.tsfile with the same contents as what @oveigam suggested (generated bycreate-tsrouter-app)I saw a similar error on both 4.1.10 and 4.0.7, but my problem was that I tried to include styles as
?urland manually append them to the head. Letting vite take care of the CSS worked just fine.Still seeing this on
4.0.8in my case.Especially when i change app.css then refresh the page.
Also seeing this error with @tanstack/start
1.107.0alongside tailwindcss4.0.7and @tailwindcss/vite4.0.7.To me the error appears every time you start the dev server and open the web for the first time: In production seems to happen every time i refresh the page
I think i found a workaround using postcss
Remove the vite plugin from app.config.ts
Install postcss and @tailwindcss/postcss
Add the following postcss.config.mjs to your root folder
Yeah everything works fine with what I showed in my original comment
going to close this now that the latest tailwindcss plugin seems to have resolved this issue. if anyone encounters any problem here, please open up a new issue including a complete example.
Also seeing this on
1.121.27, downgrading to@tailwindcss/vite@4.0.7fixed the hydration error which was being caused by a non existent css file being linked.Hi, the issue still happens in the alpha version
1.121.0-alpha.27or at least for me, the only way to fix it in my side was to downgrade the TailwindCSS Vite plugin to4.0.7.From
4.0.8some logic in the plugin changed in the way the classes are searched (see https://github.com/tailwindlabs/tailwindcss/discussions/16958#discussion-8042351).ps: I tried all the solutions of switching to PostCSS, use
source, etc…