You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After a year of feature development, this release focuses on streamlining the API surface while maintaining the core architecture of `next-intl`. With many improvements already released in [previous minor versions](/blog/next-intl-3-22), this update introduces several enhancements that will improve your development experience and make working with internationalization even more seamless.
13
13
@@ -44,7 +44,7 @@ declare module 'next-intl' {
44
44
}
45
45
```
46
46
47
-
See the updated [TypeScript augmentation](https://v4.next-intl.dev/docs/workflows/typescript) guide.
47
+
See the updated [TypeScript augmentation](/docs/workflows/typescript) guide.
48
48
49
49
## Strictly-typed locale
50
50
@@ -65,7 +65,7 @@ declare module 'next-intl' {
65
65
66
66
By doing so, APIs like `useLocale()` or `<Link />` that either return or receive a `locale` will now pick up your app-specific `Locale` type, improving type safety across your app.
67
67
68
-
To simplify narrowing of `string`-based locales, a `hasLocale` function has been added. This can for example be used in [`i18n/request.ts`](https://v4.next-intl.dev/docs/getting-started/app-router/with-i18n-routing#i18n-request) to return a valid locale:
68
+
To simplify narrowing of `string`-based locales, a `hasLocale` function has been added. This can for example be used in [`i18n/request.ts`](/docs/getting-started/app-router/with-i18n-routing#i18n-request) to return a valid locale:
Due to a current limitation in TypeScript, this feature is opt-in for now. Please refer to the [strict arguments](https://v4.next-intl.dev/docs/workflows/typescript#messages-arguments) docs to learn how to enable it.
151
+
Due to a current limitation in TypeScript, this feature is opt-in for now. Please refer to the [strict arguments](/docs/workflows/typescript#messages-arguments) docs to learn how to enable it.
152
152
153
153
## GDPR compliance [#gdpr-compliance]
154
154
155
155
In order to comply with the current GDPR regulations, the following changes have been made and are relevant to you if you're using the `next-intl` middleware for i18n routing:
156
156
157
-
1. The locale cookie now defaults to a session cookie that expires when a browser is closed.
157
+
1. The locale cookie now defaults to a session cookie that expires when the browser is closed.
158
158
2. The locale cookie is now only set when a user switches to a locale that doesn't match the `accept-language` header.
159
159
160
160
If you want to increase the cookie expiration, e.g. because you're informing users about the usage of cookies or if GDPR doesn't apply to your app, you can use the `maxAge` attribute to do so:
Since the cookie is now only available after a locale switch, make sure to not rely on it always being present. E.g. if you need access to the user's locale in a [Route Handler](https://v4.next-intl.dev/docs/environments/actions-metadata-route-handlers#route-handlers), a reliable option is to provide the locale as a search param (e.g. `/api/posts/12?locale=en`).
177
+
Since the cookie is now only available after a locale switch, make sure to not rely on it always being present. E.g. if you need access to the user's locale in a [Route Handler](/docs/environments/actions-metadata-route-handlers#route-handlers), a reliable option is to provide the locale as a search param (e.g. `/api/posts/12?locale=en`).
178
178
179
-
As part of this change, disabling a cookie now requires you to set [`localeCookie: false`](https://v4.next-intl.dev/docs/routing#locale-cookie) in your routing configuration. Previously, `localeDetection: false` ambiguously also disabled the cookie from being set, but since a separate `localeCookie` option was introduced recently, this should now be used instead.
179
+
As part of this change, disabling a cookie now requires you to set [`localeCookie: false`](/docs/routing#locale-cookie) in your routing configuration. Previously, `localeDetection: false` ambiguously also disabled the cookie from being set, but since a separate `localeCookie` option was introduced recently, this should now be used instead.
180
180
181
-
Learn more in the [locale cookie](https://v4.next-intl.dev/docs/routing#locale-cookie) docs.
181
+
Learn more in the [locale cookie](/docs/routing#locale-cookie) docs.
182
182
183
183
## Modernized build output
184
184
@@ -266,7 +266,7 @@ This will create the following structure:
266
266
-`example.no`: `no-NO`
267
267
-`example.no/en`: `en-NO`
268
268
269
-
Learn more in the updated docs for [`domains`](https://v4.next-intl.dev/docs/routing#domains).
269
+
Learn more in the updated docs for [`domains`](/docs/routing#domains).
270
270
271
271
## Preparation for upcoming Next.js features [#nextjs-future]
272
272
@@ -300,11 +300,9 @@ For a smooth upgrade, please initially upgrade to the latest v3.x version and ch
300
300
Afterwards, you can upgrade by running:
301
301
302
302
```
303
-
npm install next-intl@v4-beta
303
+
npm install next-intl@4
304
304
```
305
305
306
-
The beta docs are available here: [v4.next-intl.dev](https://v4.next-intl.dev)
307
-
308
306
I'd love to hear about your experiences with `next-intl@4.0`! Join the conversation in the [discussions](https://github.com/amannn/next-intl/discussions/1631).
309
307
310
308
## Thank you!
@@ -315,6 +313,8 @@ A special thank you goes to <PartnerContentLink href="https://crowdin.com/">Crow
315
313
316
314
—Jan
317
315
316
+
(this post has been updated from an initial announcement for the 3.0 release candidate)
317
+
318
318
PS: Have you heard that [learn.next-intl.dev](https://learn.next-intl.dev) is coming?
0 commit comments