Skip to content

feat: Add localeCookie option for middleware#1414

Merged
amannn merged 6 commits intocanaryfrom
feat/cookie-opts
Oct 10, 2024
Merged

feat: Add localeCookie option for middleware#1414
amannn merged 6 commits intocanaryfrom
feat/cookie-opts

Conversation

@amannn
Copy link
Copy Markdown
Owner

@amannn amannn commented Oct 10, 2024

Users have in various issues expressed the interest for customization of the locale cookie that the middleware sets. This PR adds such a capability via a new localeCookie option that can be configured via defineRouting:

import {defineRouting} from 'next-intl/routing';

export const routing = defineRouting({
  // ...
  localeCookie: {
    // Expire in 5 hours
    maxAge: 60 * 60 * 5
  }
});

… or turn the cookie off entirely:

import {defineRouting} from 'next-intl/routing';

export const routing = defineRouting({
  // ...
  localeCookie: false
});

See also: Proposed docs


Fixes #454
Fixes #1268

@vercel
Copy link
Copy Markdown

vercel Bot commented Oct 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-intl-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 10, 2024 3:28pm
next-intl-example-app-router ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 10, 2024 3:28pm
next-intl-example-app-router-without-i18n-routing ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 10, 2024 3:28pm

# Conflicts:
#	examples/example-app-router-playground/tests/main.spec.ts
juanforlizzi pushed a commit to juanforlizzi/next-intl that referenced this pull request Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant