-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Svelte 5 Hydration mismatch (with adapter-static) #11509
Comments
If you open the dev tools and enable pause on exception, it should stop on the error that occurs that is causing the hydration error. Can you show what that is please? Also interestingly, it seems that |
I don't know if it can be of any help, but I had the first mentioned error. It occurred only when SSR was disabled. And after updating vite, svelte-kit, and the adapter to the latest version, it fixed the issue. This is a simplified setup that causes the error:
{
...
"devDependencies": {
"@sveltejs/adapter-node": "^1.0.0",
"@sveltejs/kit": "^1.20.4",
"svelte": "^5.0.0-next.125",
"vite": "^4.0.0"
}
}
export const ssr = false;
<h1>Hello</h1> |
I havent been able to reproduce it in an isolated situation working from an empty project yet... I need to take some time probably next week to start from my app situation and break it down. |
Please can you try the latest version of Svelte 5. |
Sounds like your node_modules might need removing and re-installing. It looks like you removed vite-plugin-svelte too? |
Almost positive I already did that, but will try again tomorrow |
Hi... In my project i keep getting this. Guess it depends on too many moving parts. Within my project I have been able to stop causing the problem by making some small changes to my pages/components But it remains weird to me that it throws Cannot read properties of null (reading 'name') in below situation I am going to park this for now, so feel free to close the issue. |
If you render you app without SSR, does that error go away? |
I'm having the same issue, but with the bun adapter, which is a variant of the node adapter. Can't seem to pin down exactly what's causing it. |
Hey @trueadm, CONFIRMED. Turning off SSR removed this error. What can you tell us that you might know? Maybe collectively we can figure this out? My project is complaining about a line of code in bits-ui library which is included with shadcn-svelte. I thought maybe that was it, then I remembered a fresh instance of the Svelte Demo app at creation (the game) also gives this error. |
Major update: Look for this issue with the markup concerning labels and inputs. Let's confirm if this is what's causing other people's issues. The second version is what I had, and it was breaking hydration in SSR mode with the Bun adapter. The working variant is the first one. <label>The Label
<input />
</label>
vs
<label>The Label</label>
<input /> |
The second is missing the closing tag? |
Sorry, i mistyped the example. The tag was indeed and correctly self closed. I'm trying to convey the label wrapped input tag vs non wrapped. |
That’s strange. Can you create a minimal repro that shows the second example failing with hydration? I just tried and it seems to work fine for me |
Ugh. Now I can't seem to reproduce this. I thought for sure I nailed it down. |
UPDATE: Turns out, Bun was caching old files. I'm no longer getting the errors after forcefully and manually removing all traces of cache and reinstalling packages. So if you continue to have these errors, give deep cleaning of cache a try. |
Describe the bug
Using Svelte 5 with my unchanged (working) Svelte(Kit) Application throws an error.
Not sure how to explain what happens, but a clue could be that I use adapter static?
Reproduction
I dont have the time at the moment to produce a clean reproduction scenario, hopefully there are enough clues from the screenshot.
Maybe I just needed to update some of the related packages?
Logs
System Info
Severity
blocking an upgrade
The text was updated successfully, but these errors were encountered: