Hydration node mismatch with `.server`/`.client` components
See original GitHub issueEnvironment
- Operating System:
Linux
- Node Version:
v16.14.2
- Nuxt Version:
3.0.0
- Nitro Version:
1.0.0
- Package Manager:
npm@7.17.0
- Builder:
vite
- User Config:
-
- Runtime Modules:
-
- Build Modules:
-
Reproduction
https://stackblitz.com/edit/github-uy1uwl?file=app.vue
Describe the bug
According to the docs, server-side rendered .server
components are replaced with their .client
counterparts on the client-side. Unfortunately, this isn’t working as expected and Vue throws an Hydration node mismatch
warning even though both files contain the same template without any state dependent dynamic content.
<template>
<h1>Hello World!</h1>
</template>
Additional context
No response
Logs
[Vue warn]: Hydration node mismatch:
- Client vnode: div
- Server rendered DOM: <h1>Hello World!</h1>
at <Headline.client>
at <App key=1 >
at <NuxtRoot>
Issue Analytics
- State:
- Created 10 months ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
[Vue warn]: Hydration node mismatch: · Issue #1310 - GitHub
[Vue warn]: Failed to resolve component: client-only If this is a native custom element, make sure to exclude it from component resolution via ......
Read more >Understand and solve hydration errors in Vue.js - sum.cumo
Hydration refers to the client-side process during which Vue takes over the static HTML sent by the server and turns it into dynamic...
Read more >Hydration Mismatch - vite-plugin-ssr
A hydration mismatch is when the content rendered to HTML in Node.js is not the same than the content rendered in the browser....
Read more >Should I ignore these kind of warnings? "Hydration node ...
I am using this package "FormKit" for handling forms and validation. it shows this warning for every element I use and I can't...
Read more >Handling the React server hydration mismatch error
How to resolve the server mismatch error when hydrating a shared React component that can be used in client-side only or server-side rendered ......
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 Free
Top 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
@harlan-zw it’s weird… i’ve checked it out… but take a look at this once: https://stackblitz.com/edit/github-uy1uwl-8peita?file=app.vue it’s some how working fine with this approach in this repo.
@RajendraUppu you added the
<div>
tag inapp.vue
while @harlan-zw added it to the component template.I can confirm that wrapping
<Headline />
inside a<div>
inapp.vue
resolves the issue. If that is for technical reasons, we should point it out in the docs. I consider wrapping everything in adiv
for no reason bad practice and wouldn’t normally do that.The duplication of the component @harlan-zw pointed out seems to be an issue on its own. It still happens if the hydration error is resolved with the approach above. I suggest we move that to its own issue.
Therefore the remaining question on this issue is: Do we need a
<div>
around the component in the parent element or is it a bug?