vercel / vercel/next.js

Docs: NEXT_LOCALE cookie

Open Beginner friendly
#49,339 0 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
142k
Forks
32.4k
Avg merge
2d 14h
Merged PRs (30d)
351

Description

What is the improvement or update you wish to see?

This functionality is explained to just blanket work, but it doesn't. If implementing a locale / language switcher with full domain switching, the cookie can only be set on the current domain and thus doesn't carry when you get to the other domain. It should be explained that this method can only work when operating off of a single domain.

Is there any context that might help us understand?

Let's say I have 2 domains:
example.co (for en-US) and example.ca (for en-CA)

As a US visitor who visits the example.ca site, I am redirected to example.co (good).

Upon interacting with the language switcher to force the Canada locale, we can set the NEXT_LOCALE cookie on the example.co domain (the domain we're on), but we can't set the cookie on example.ca (the domain we want to be on) because of the Same Origin Policy. Now when our language switcher interacts with the router to send us to the example.ca domain, the cookie isn't present and we get redirected back to example.co. Sad.

Does the docs page already exist? Please link to it.

https://nextjs.org/docs/pages/building-your-application/routing/internationalization

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open the linked internationalization documentation page and find the section describing the NEXT_LOCALE cookie. Clarify that this approach works for a single domain and that the cookie cannot be carried across separate domains such as example.co and example.ca; the documentation is done when this limitation is explicit.

Written by the indexing model from the issue text.

Assessment

Tech stack
nextjs
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.