diff --git a/docs/package.json b/docs/package.json index b5b2f4259..cb30c4947 100644 --- a/docs/package.json +++ b/docs/package.json @@ -16,7 +16,7 @@ "@vercel/analytics": "^1.0.1", "clsx": "^1.2.1", "http-status-codes": "^2.2.0", - "next": "^13.4.7", + "next": "13.4.7", "nextra": "^2.8.0", "nextra-theme-docs": "^2.8.0", "react": "^18.2.0", diff --git a/examples/example-advanced/package.json b/examples/example-advanced/package.json index 721668694..b50962de5 100644 --- a/examples/example-advanced/package.json +++ b/examples/example-advanced/package.json @@ -12,8 +12,8 @@ "dependencies": { "accept-language-parser": "^1.5.0", "lodash": "^4.17.21", - "next": "^13.4.7", - "next-intl": "^2.14.3", + "next": "13.4.7", + "next-intl": "latest", "react": "^18.2.0", "react-dom": "^18.2.0" }, diff --git a/examples/example-next-13-next-auth/package.json b/examples/example-next-13-next-auth/package.json index c4ce98006..ed764e31f 100644 --- a/examples/example-next-13-next-auth/package.json +++ b/examples/example-next-13-next-auth/package.json @@ -10,9 +10,9 @@ "start": "next start" }, "dependencies": { - "next": "^13.4.7", + "next": "13.4.7", "next-auth": "^4.22.1", - "next-intl": "^2.14.3", + "next-intl": "latest", "react": "^18.2.0", "react-dom": "^18.2.0" }, diff --git a/examples/example-next-13/package.json b/examples/example-next-13/package.json index 7a5ea0fa8..619be4e6a 100644 --- a/examples/example-next-13/package.json +++ b/examples/example-next-13/package.json @@ -13,8 +13,8 @@ }, "dependencies": { "clsx": "^1.2.1", - "next": "^13.4.7", - "next-intl": "^2.14.3", + "next": "13.4.7", + "next-intl": "latest", "react": "^18.2.0", "react-dom": "^18.2.0", "tailwindcss": "^3.2.4" diff --git a/examples/example-next-13/tests/main.spec.ts b/examples/example-next-13/tests/main.spec.ts index 456449468..642156fe1 100644 --- a/examples/example-next-13/tests/main.spec.ts +++ b/examples/example-next-13/tests/main.spec.ts @@ -51,7 +51,10 @@ it('can be used to localize the page', async ({page}) => { it('sets a cookie', async ({page}) => { const response = await page.goto('/'); - expect(await response?.headerValue('set-cookie')).toBe( - 'NEXT_LOCALE=en; Path=/; SameSite=strict' - ); + const value = await response?.headerValue('set-cookie'); + expect(value).toContain('NEXT_LOCALE=en;'); + expect(value).toContain('Path=/;'); + expect(value).toContain('SameSite=strict'); + expect(value).toContain('Max-Age=31536000;'); + expect(value).toContain('Expires='); }); diff --git a/examples/example/package.json b/examples/example/package.json index 9618c3faf..96f2cd3c4 100644 --- a/examples/example/package.json +++ b/examples/example/package.json @@ -11,8 +11,8 @@ }, "dependencies": { "date-fns": "^2.16.1", - "next": "^13.4.7", - "next-intl": "^2.14.3", + "next": "13.4.7", + "next-intl": "latest", "react": "^18.2.0", "react-dom": "^18.2.0" }, diff --git a/packages/next-intl/package.json b/packages/next-intl/package.json index dda2fdc56..3ad512225 100644 --- a/packages/next-intl/package.json +++ b/packages/next-intl/package.json @@ -83,7 +83,7 @@ "eslint": "^8.39.0", "eslint-config-molindo": "^6.0.0", "eslint-plugin-deprecation": "^1.4.1", - "next": "^13.4.7", + "next": "13.4.7", "react": "^18.2.0", "react-dom": "^18.2.0", "size-limit": "^8.2.6", diff --git a/packages/next-intl/src/client/useClientLocale.tsx b/packages/next-intl/src/client/useClientLocale.tsx index a4e7036d2..a407fe031 100644 --- a/packages/next-intl/src/client/useClientLocale.tsx +++ b/packages/next-intl/src/client/useClientLocale.tsx @@ -9,7 +9,7 @@ export default function useClientLocale(): string { // `useParams` can be called, but the return type is `null`. const params = useParams() as ReturnType | null; - if (params?.[LOCALE_SEGMENT_NAME]) { + if (typeof params?.[LOCALE_SEGMENT_NAME] === 'string') { locale = params[LOCALE_SEGMENT_NAME]; } else { // eslint-disable-next-line react-hooks/rules-of-hooks -- Reading from context conditionally is fine diff --git a/packages/next-intl/src/middleware/middleware.tsx b/packages/next-intl/src/middleware/middleware.tsx index bb0bfbf2e..c4663156e 100644 --- a/packages/next-intl/src/middleware/middleware.tsx +++ b/packages/next-intl/src/middleware/middleware.tsx @@ -185,7 +185,8 @@ export default function createMiddleware(config: MiddlewareConfig) { if (hasOutdatedCookie) { response.cookies.set(COOKIE_LOCALE_NAME, locale, { - sameSite: 'strict' + sameSite: 'strict', + maxAge: 31536000 // 1 year }); } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 51fc18af4..302746892 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.1' +lockfileVersion: '6.0' settings: autoInstallPeers: true @@ -33,7 +33,7 @@ importers: specifier: ^2.2.0 version: 2.2.0 next: - specifier: ^13.4.7 + specifier: 13.4.7 version: 13.4.7(@babel/core@7.22.5)(react-dom@18.2.0)(react@18.2.0) nextra: specifier: ^2.8.0 @@ -71,7 +71,7 @@ importers: version: 13.4.0(eslint@8.39.0)(typescript@5.0.4) next-sitemap: specifier: ^4.0.7 - version: 4.0.7(@next/env@13.4.7)(next@13.4.7) + version: 4.0.7(@next/env@13.4.12)(next@13.4.7) prettier-plugin-tailwindcss: specifier: ^0.2.3 version: 0.2.3(prettier@2.8.8) @@ -85,10 +85,10 @@ importers: specifier: ^2.16.1 version: 2.16.1 next: - specifier: ^13.4.7 + specifier: 13.4.7 version: 13.4.7(@babel/core@7.22.5)(react-dom@18.2.0)(react@18.2.0) next-intl: - specifier: ^2.14.3 + specifier: latest version: link:../../packages/next-intl react: specifier: ^18.2.0 @@ -128,10 +128,10 @@ importers: specifier: ^4.17.21 version: 4.17.21 next: - specifier: ^13.4.7 + specifier: 13.4.7 version: 13.4.7(@babel/core@7.22.5)(react-dom@18.2.0)(react@18.2.0) next-intl: - specifier: ^2.14.3 + specifier: latest version: link:../../packages/next-intl react: specifier: ^18.2.0 @@ -183,10 +183,10 @@ importers: specifier: ^1.2.1 version: 1.2.1 next: - specifier: ^13.4.7 + specifier: 13.4.7 version: 13.4.7(@babel/core@7.22.5)(react-dom@18.2.0)(react@18.2.0) next-intl: - specifier: ^2.14.3 + specifier: latest version: link:../../packages/next-intl react: specifier: ^18.2.0 @@ -250,13 +250,13 @@ importers: examples/example-next-13-next-auth: dependencies: next: - specifier: ^13.4.7 + specifier: 13.4.7 version: 13.4.7(@babel/core@7.22.5)(react-dom@18.2.0)(react@18.2.0) next-auth: specifier: ^4.22.1 version: 4.22.1(next@13.4.7)(react-dom@18.2.0)(react@18.2.0) next-intl: - specifier: ^2.14.3 + specifier: latest version: link:../../packages/next-intl react: specifier: ^18.2.0 @@ -407,7 +407,7 @@ importers: specifier: ^1.4.1 version: 1.4.1(eslint@8.39.0)(typescript@5.0.4) next: - specifier: ^13.4.7 + specifier: 13.4.7 version: 13.4.7(@babel/core@7.22.5)(react-dom@18.2.0)(react@18.2.0) react: specifier: ^18.2.0 @@ -5111,6 +5111,10 @@ packages: '@napi-rs/simple-git-win32-x64-msvc': 0.1.8 dev: false + /@next/env@13.4.12: + resolution: {integrity: sha512-RmHanbV21saP/6OEPBJ7yJMuys68cIf8OBBWd7+uj40LdpmswVAwe1uzeuFyUsd6SfeITWT3XnQfn6wULeKwDQ==} + dev: true + /@next/env@13.4.7: resolution: {integrity: sha512-ZlbiFulnwiFsW9UV1ku1OvX/oyIPLtMk9p/nnvDSwI0s7vSoZdRtxXNsaO+ZXrLv/pMbXVGq4lL8TbY9iuGmVw==} @@ -18300,7 +18304,7 @@ packages: react-dom: 18.2.0(react@18.2.0) dev: false - /next-sitemap@4.0.7(@next/env@13.4.7)(next@13.4.7): + /next-sitemap@4.0.7(@next/env@13.4.12)(next@13.4.7): resolution: {integrity: sha512-S2g5IwJeO0+ecmFq981fb+Mw9YWmntOuN/qTCxclSkUibOJ8qKIOye0vn6NEJ1S4tKhbY+MTYKgJpNdFZYxLoA==} engines: {node: '>=14.18'} hasBin: true @@ -18309,7 +18313,7 @@ packages: next: '*' dependencies: '@corex/deepmerge': 4.0.43 - '@next/env': 13.4.7 + '@next/env': 13.4.12 minimist: 1.2.8 next: 13.4.7(@babel/core@7.22.5)(react-dom@18.2.0)(react@18.2.0) dev: true