next.js
next.js copied to clipboard
feat: allowing user to specify i18n cookie name on config
Feature
Implements the feature as suggested in #24852. Our use case is that we have multiple apps managed by different teams and we want to have a frictionless experience through all of them. One part of it is to preserve the same language. Some of our apps are in NextJS and it would be great if we don't have to force other teams to follow the NextJS convention.
I have not added integration tests because the fixture is pretty much locked with the NEXT_LOCALE default cookie, which I think is right, but let me know what you think about that.
- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [x] Related issues linked using
implements #24852 - [ ] Integration tests added
- [x] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see
contributing.md
Documentation / Examples
- [x] Make sure the linting passes by running
yarn lint - [x] Added setting to the
docs
How to test
- Create a i18n project. e.g.
yarn create next-app --example i18n-routing i18n-app - Check out this branch and link the project as per the guidelines
- Run the project with
yarn dev - Open a browser (e.g. Firefox) and add the
NEXT_LOCALEcookie value tofr - Go to
localhost:3000and check that it goes to thefrlocale. So far so good. - Now add the new property
cookieName: customto thenext.config.js - Add now a cookie called
customwith valuenl - Go to
localhost:3000and check that it goes to thefrlocale. - Happy days