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 Error Due to Locale-based Redirect in Static Site with Browser Language Detection. #3084

Open
besfir opened this issue Sep 4, 2024 · 3 comments

Comments

@besfir
Copy link

besfir commented Sep 4, 2024

Environment


  • Operating System: Darwin
  • Node Version: v20.10.0
  • Nuxt Version: 3.13.0
  • CLI Version: 3.13.1
  • Nitro Version: 2.9.7
  • Package Manager: [email protected]
  • Builder: -
  • User Config: compatibilityDate, devtools, modules, i18n
  • Runtime Modules: @nuxtjs/[email protected]
  • Build Modules: -

Reproduction

https://github.com/besfir/i18n_reproduction

Describe the bug

Issue

A Hydration completed but contains mismatches error occurs when the root page is redirected to another language page based on browser language detection in a statically generated site.

Reproduction Steps

  1. Use locale messages in the template.
  2. Make it so that the detectBrowserLanguage cookie stores a non-default locale.
  3. Directly access the root page, which triggers a redirect based on the locale saved in the cookie, resulting in a hydration error.

Demo

screencast.2024-09-04.10-26-33.mp4

Additional context

No response

Logs

No response

@BobbieGoede
Copy link
Collaborator

Can you confirm if you're still experiencing hydration errors with the latest patch release?

@besfir
Copy link
Author

besfir commented Sep 5, 2024

I updated the nuxt-i18n module to the latest version, but the error still occurs. I've also applied it to the reproduction.

@marcbelletre
Copy link

I have the same issue with latest version (8.5.5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants