Skip to content
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

Hydration attribute mismatch after update Nuxt to v3.9.0 #1171

Closed
ivan-mihalic opened this issue Dec 29, 2023 · 42 comments · Fixed by #1199
Closed

Hydration attribute mismatch after update Nuxt to v3.9.0 #1171

ivan-mihalic opened this issue Dec 29, 2023 · 42 comments · Fixed by #1199
Labels
bug Something isn't working

Comments

@ivan-mihalic
Copy link
Sponsor

Environment

  • Operating System: Linux
  • Node Version: v18.18.0
  • Nuxt Version: 3.9.0
  • CLI Version: 3.10.0
  • Nitro Version: 2.8.1
  • Package Manager: yarn@1.22.19
  • Builder: -
  • User Config: devtools, modules, ui
  • Runtime Modules: @nuxt/ui@2.11.1
  • Build Modules: -

Version

v2.11.1

Reproduction

https://stackblitz.com/edit/nuxt-starter-5tmfpt?file=components%2FUserForm.vue

Description

Hi guys,
I updated Nuxt to version 3.9.0 and I am getting Hydration attribute mismatch for example on USelectMenu or UDropdown viz screenshot. I think it is a bug and it is now showing after improve ssr hydration mismatch checks in Vue 3.4.

CleanShot 2023-12-29 at 17 38 06@2x

Additional context

No response

Logs

No response

@ivan-mihalic ivan-mihalic added the bug Something isn't working label Dec 29, 2023
@MickL
Copy link

MickL commented Dec 29, 2023

I do have the same issue

@hoanghadu
Copy link

I have the same issue

@ellellie
Copy link

ellellie commented Jan 2, 2024

Also occurring with UCheckbox, here's a minimal reproduction (app.vue):

<template>
  <UCheckbox v-model="state" label="Test checkbox" />
</template>

<script setup lang="ts">
const state = ref(true)
</script>

Notably does not occur when the ref is false.

Testing against 2.11.1 and 7151b7b with nuxt@3.9.0 both yield the same result.
image

@pixelpaulaus
Copy link

getting same things now after the update

@tabuz
Copy link

tabuz commented Jan 2, 2024

I also got plenty of hydration mismatch after upgrade.

@marco94gug
Copy link

marco94gug commented Jan 2, 2024

same bug but without info after upgrade to 3.9.0
I tried with --no-force and --force and i have the same issue

Screenshot 2024-01-02 at 15 09 50

@ahoiroman
Copy link

Same here with ui-pro/landing template

Copy link
Member

I think this is due to latest vue 3.4, we have to override all of Headless UI generated ids with the future useId composable from Nuxt: nuxt/nuxt#23368 but it hasn't been released yet.

In the meantime, can you try to set the resolution to vue to 3.3.13?

@benjamincanac benjamincanac changed the title Hydratation attribute mismatch after update Nuxt to v3.9.0 Hydration attribute mismatch after update Nuxt to v3.9.0 Jan 3, 2024
@yoricktran
Copy link

I think this is due to latest vue 3.4, we have to override all of Headless UI generated ids with the future useId composable from Nuxt: nuxt/nuxt#23368 but it hasn't been released yet.

In the meantime, can you try to set the resolution to vue to 3.3.13?

3.3.13 fixed it for me for now, thanks!

@whcxxb
Copy link

whcxxb commented Jan 8, 2024

Nuxt3.9.1 still has this problem and 3.3.13 can solve it

@tabuz
Copy link

tabuz commented Jan 8, 2024

Sorry for anoob question, but how did you achieved to pin vue@3.3.13?

My package.json looks like below

{
  "private": true,
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare"
  },
  "dependencies": {
    "@nuxt/ui": "^2.11.0",
    "@nuxtjs/google-fonts": "^3.1.0",
    "@pinia/nuxt": "^0.5.1",
    "consola": "^3.2.3",
    "nuxt-proxy": "^0.4.1",
    "pinia": "^2.1.7",
    "sass": "^1.69.5",
    "vue": "^3.3.9",
    "zod": "^3.22.4"
  },
  "devDependencies": {
    "@iconify/vue": "^4.1.1",
    "@nuxt/devtools": "^1.0.3",
    "@nuxtjs/i18n": "^8.0.0-rc.5",
    "@vueuse/core": "^10.6.1",
    "@vueuse/nuxt": "^10.6.1",
    "nuxt": "^3.9.0",
    "prettier": "^3.1.0",
    "prettier-plugin-tailwindcss": "^0.5.7"
  }
}

Copy link
Member

You need to set it in resolutions:

{
  "private": true,
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare"
  },
  "dependencies": {
    "@nuxt/ui": "^2.11.0",
    "@nuxtjs/google-fonts": "^3.1.0",
    "@pinia/nuxt": "^0.5.1",
    "consola": "^3.2.3",
    "nuxt-proxy": "^0.4.1",
    "pinia": "^2.1.7",
    "sass": "^1.69.5",
    "vue": "^3.3.9",
    "zod": "^3.22.4"
  },
  "devDependencies": {
    "@iconify/vue": "^4.1.1",
    "@nuxt/devtools": "^1.0.3",
    "@nuxtjs/i18n": "^8.0.0-rc.5",
    "@vueuse/core": "^10.6.1",
    "@vueuse/nuxt": "^10.6.1",
    "nuxt": "^3.9.0",
    "prettier": "^3.1.0",
    "prettier-plugin-tailwindcss": "^0.5.7"
  },
  "resolutions": {
    "vue": "3.3.13"
  }
}

@tabuz
Copy link

tabuz commented Jan 8, 2024

@benjamincanac Thank you for quick reply. I've tried what you suggested and while executing npm list vue is shows as vue@3.4.5 deduped everywhere and app itself still throws hydration mismatch.

npm package.json docs doesnt mention usage of keyword resolutions. Should I use this package https://www.npmjs.com/package/npm-force-resolutions ?

Copy link
Member

Oh sorry, this is for yarn and pnpm. It seems you can use overrides with npm since 8.3.0.

@lammerfalcon
Copy link
Contributor

i have the same issue with UTable - hydration mistmaches - warning on UCheckbox inside table component
really dont want to downgrade versions(( any info when we can get update?

@dolbex
Copy link

dolbex commented Jan 10, 2024

This seems related as well. See the following reproduction:

https://stackblitz.com/edit/nuxt-starter-t3xebe?file=components%2FAttributeTest.vue

I have a form with a dynamic action attribute. I even understand the hydration attr mismatch but why is the value wrong on initial load. It should have loaded with "something" and then changed to the clientside date/time. It can change based on the button click. This was unexpected for us.

@RomanSkrypnik
Copy link

I'm facing the same issue

@sync42johnny
Copy link

sync42johnny commented Jan 10, 2024

i do have the same issue -\^-^/-

@jontybrook
Copy link

jontybrook commented Jan 10, 2024

Ditto here.. causing all sorts of mismatches with a whole bunch of deps (headless, radix, etc etc). Think the best fix is upstream in vue?

I'm using Bun, which supports both the overrides and resolutions syntax. So the temporary solution for me is in package.json:

"overrides": { "vue": "3.3.13" },

@jianggangsheng
Copy link

Nuxt3.9.1仍然有这个问题,3.3.13可以解决

所以是要降低版本来解决这个问题吗

@jianggangsheng
Copy link

同样发生在UCheckbox,这里是一个最小的复制(app.vue):

<template>
  <UCheckbox v-model="state" label="Test checkbox" />
</template>

<script setup lang="ts">
const state = ref(true)
</script>

值得注意的是,当 ref 为 false 时不会发生。

针对 2.11.1 和7151b7b进行的测试均nuxt@3.9.0产生相同的结果。 图像

问题解决了吗

Copy link
Member

It seems Vue will have its own useId composable in 3.5: https://twitter.com/youyuxi/status/1745379112456429688.

@cco3
Copy link

cco3 commented Jan 20, 2024

I get the sense you all already understand the root issue, but sense I haven't seen anyone mention it, I'm also seeing this with UTabs.

@joeldegerman99
Copy link

I have the same issue with UDropdown

@iyefreedy
Copy link

iyefreedy commented Jan 25, 2024

I have the same issue with UDropdown

Nuxt Version: 3.9.3
Nuxt UI Version: 2.11.1
image

@marcobax
Copy link

The same issue occurs with Popoverbutton too

Nuxt Version: 3.9.3
Headlessui UI Version: 1.7.16

Screenshot 2024-01-25 at 19 03 16

Copy link
Member

Those warnings will appear for the all components using Headless UI underneath. The only fix for now is to pin vue to 3.3.13 while waiting for Vue 3.5 and its useId composable.

Those hydration issues were already present but only displayed since Vue 3.4.

@zacwebb
Copy link

zacwebb commented Jan 31, 2024

Nuxt has shipped a useId composable in 3.10.0 👀

@ybw0014
Copy link

ybw0014 commented Jan 31, 2024

#1211

@abyshake-anand
Copy link

Seeing the same issue...
Using UDropdown

  • Nuxt ^3.9.3
  • vue ^3.3.13

"resolutions": {
"vue": "3.3.13"
}

@pedrodruviaro
Copy link

Same issue with a lot of NuxtUi componentes... even with the "resolutions" option

@madebyfabian
Copy link
Sponsor

madebyfabian commented Feb 8, 2024

Even after overriding, these issues still persist. Not sure if I've done it right though. I am using pnpm- Tested overrides, resolutions and pnpm.overrides

@dandonovan78
Copy link

dandonovan78 commented Feb 13, 2024

I had a bit of trouble overriding the version with npm, causing some dependency issues. After some fiddling, adding an override specifically for nuxt seems to work to set the vue version to 3.3.13 and also eliminates the hydration mismatch errors:

"overrides": {
    "nuxt": {
      "vue": "3.3.13"
    },
  },

@Poraksis
Copy link

"dependencies": {
"flowbite": "^2.2.1",
"nuxt": "^3.10.1",
"vue": "^3.4.15",
"vue-router": "^4.2.5"
}

i have so much hydration mismatch errors so just removed nuxt ui kit, any suggestion ?

Copy link
Member

@Poraksis There are already tons of comments in this issue answering that already: #1171 (comment)

This issue has already been solved and will be released this week in v2.14.0.

@m0k99
Copy link

m0k99 commented Feb 24, 2024

I have the same issue

Copy link
Member

@m0k99 Do you still encounter this issue with https://github.com/nuxt/ui/releases/tag/v2.14.0?

@m0k99
Copy link

m0k99 commented Feb 24, 2024

@m0k99 Do you still encounter this issue with https://github.com/nuxt/ui/releases/tag/v2.14.0?
in my project, I don't use NuxtUI and I write randomId in utils and use that in my component and get the following error:

  • Operating System: Linux
  • Nuxt Version: 3.9.0
  • Vue Version: 3.4.14

Screenshot from 2024-02-24 19-22-55

@cco3
Copy link

cco3 commented Feb 24, 2024

I don't use NuxtUI

This issue is about NuxtUI. If you are getting hydration mismatches without NuxtUI, it's a different problem.

I write randomId in utils

If you use a random ID in your component, what is generated on the server will differ from what's generated in the client. Naturally, you will have a hydration mismatch. You can fix this by not using a random ID.

PrimeTimeTran added a commit to PrimeTimeTran/turbo-ship that referenced this issue Mar 1, 2024
@Muslihiddin
Copy link

Muslihiddin commented Mar 19, 2024

I'm getting this warning on checkbox, but only when I reload page and checkbox is used on that page. And

    "resolutions": {
        "vue": "3.3.13"
    } 

didn't help either

@noook
Copy link
Collaborator

noook commented Mar 19, 2024

I think checkboxes have been fixed recently and not released yet

#1495

@pixelpaulaus
Copy link

Hmmm, though this was fixed in v2.14.0, but am I mistaken?
As I seem to be getting the same errors on UI Buttons with the following versions...

├── @headlessui/vue@1.7.20
├── @heroicons/vue@2.1.3
├── @nuxt/devtools@1.2.0
├── @nuxt/eslint-config@0.2.0
├── @nuxt/image@1.6.0
├── @nuxt/ui@2.15.2
├── @nuxtjs/tailwindcss@6.12.0
├── @pinia/nuxt@0.5.1
├── @silvermine/videojs-quality-selector@1.3.1
├── eslint-plugin-tailwindcss@3.15.1
├── eslint@8.57.0
├── file-saver@2.0.5
├── nuxt-delay-hydration@1.3.3
├── nuxt@3.11.2
├── pinia@2.1.7
├── rollup-plugin-cleanup@3.2.1
├── sass@1.75.0
├── unhead@1.9.7
├── video.js@8.10.0
├── vite-plugin-string-replace@1.1.2
├── vue-eslint-parser@9.4.2
├── vue-router@4.3.2
├── vue@3.4.25
└── yup@1.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.