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 with static export and redirect from / #1595

Closed
3 tasks done
rpetersen27 opened this issue Dec 5, 2024 · 2 comments
Closed
3 tasks done

Hydration error with static export and redirect from / #1595

rpetersen27 opened this issue Dec 5, 2024 · 2 comments
Labels
bug Something isn't working unconfirmed Needs triage.

Comments

@rpetersen27
Copy link

Description

I have an app with static export and set everything up as described in the docs. Everything works fine, except that I now wanted to create a redirect from / to a default language.

I then followed the instructions here https://next-intl-docs.vercel.app/docs/routing/middleware#usage-without-middleware-static-export about locale detection without middleware. I created the page in the /app folder but in order to function I had to add a layout as well.

The redirect does work fine, but since I added the page and layout in /app, I get an hydration error that states, that the lang attribute is broken. I was able to observe, that the /en page is delivered without the lang attribute even though it is set in the according layout. I recreated the issue in a repo based on the reproduction template, but I updated the packages.

Additional note: I also looked at the generated html files and the lang-attribute is also missing in the /en.html which will probably leads to the same problem in production (as far as I know. I am pretty new to the whole stack though).

Any insights and help is really appreciated.

Verifications

Mandatory reproduction URL

https://github.com/rpetersen27/next-intl-static-export-hydration-bug

Reproduction description

Steps to reproduce:

  1. Go to the reproduction repo and check it out.
  2. Run dev mode with npm run dev
  3. Open localhost:3000
  4. Observe the redirect to /en and the hydration error

Expected behaviour

  1. No hydration error
@rpetersen27 rpetersen27 added bug Something isn't working unconfirmed Needs triage. labels Dec 5, 2024
@amannn
Copy link
Owner

amannn commented Dec 6, 2024

Ah yep, thanks for the report! There was indeed a minor hint missing here.

I've just updated the section in f1fa834.

Can you have a look if this works for you?

@rpetersen27
Copy link
Author

Awesome, this works. It's actually kind of obvious now that I see it, but as always, new libs are sometimes a bit overwhelming. Thanks for the quick response and solution 👍

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

No branches or pull requests

2 participants