Skip to content

Commit c332633

Browse files
gdaybriceQuiiBz
andauthored
feat: support next@15 (#426)
Co-authored-by: Tom Lienard <tom.lienrd@gmail.com>
1 parent a049386 commit c332633

14 files changed

Lines changed: 415 additions & 148 deletions

File tree

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"dependencies": {
1212
"@vercel/analytics": "^1.1.1",
1313
"@vercel/speed-insights": "^1.0.2",
14-
"next": "^14.0.4",
14+
"next": "^15.0.0",
1515
"nextra": "^2.13.2",
1616
"nextra-theme-docs": "^2.13.2",
1717
"react": "^18.2.0",

docs/pages/docs/app-setup.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ Move all your routes inside an `app/[locale]/` folder. For Client Components, wr
5151
import { ReactElement } from 'react'
5252
import { I18nProviderClient } from '../../locales/client'
5353

54-
export default function SubLayout({ params: { locale }, children }: { params: { locale: string }, children: ReactElement }) {
54+
// If you are using Next.js < 15, you don't need to await `params`:
55+
// export default function SubLayout({ params: { locale }, children }: { params: { locale: string }, children: ReactElement }) {
56+
export default function SubLayout({ params, children }: { params: Promise<{ locale: string }>, children: ReactElement }) {
57+
const { locale } = await params
58+
5559
return (
5660
<I18nProviderClient locale={locale}>
5761
{children}

docs/pages/docs/app-static-rendering.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ Inside all pages that you want to be statically rendered, call this `setStaticPa
2222
// app/[locale]/page.tsx and any other page
2323
import { setStaticParamsLocale } from 'next-international/server'
2424

25-
export default function Page({ params: { locale } }: { params: { locale: string } }) {
25+
// If you are using Next.js < 15, you don't need to await `params`:
26+
// export default function Page({ params: { locale } }: { params: { locale: string } }) {
27+
export default function Page({ params }: { params: Promise<{ locale: string }> }) {
28+
const { locale } = await params
2629
setStaticParamsLocale(locale)
2730

2831
return (

docs/pages/docs/rtl-support.mdx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ If you want to support the `dir` attribute in your `<html>` tag, you'll need to
88

99
```tsx {3,6}
1010
// app/[locale]/layout.tsx
11-
export default function Layout({ children, params: { locale } }: { children: ReactElement, params: { locale: string } }) {
11+
12+
// If you are using Next.js < 15, you don't need to await `params`:
13+
// export default function Layout({ children, params: { locale } }: { children: ReactElement, params: { locale: string } }) {
14+
export default function Layout({ children, params }: { children: ReactElement, params: Promise<{ locale: string }> }) {
15+
const { locale } = await params
1216
const dir = new Intl.Locale(locale).getTextInfo().direction
1317

1418
return (
@@ -56,7 +60,10 @@ Then, use it instead of the native `Intl.Locale.prototype.getTextInfo` API:
5660
// app/[locale]/layout.tsx
5761
import Locale from 'intl-locale-textinfo-polyfill'
5862

59-
export default function Layout({ children, params: { locale } }: { children: ReactElement, params: { locale: string } }) {
63+
// If you are using Next.js < 15, you don't need to await `params`:
64+
// export default function Layout({ children, params: { locale } }: { children: ReactElement, params: { locale: string } }) {
65+
export default function Layout({ children, params }: { children: ReactElement, params: Promise<{ locale: string }> }) {
66+
const { locale } = await params
6067
const { direction: dir } = new Locale(locale).textInfo
6168

6269
return (
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import type { ReactNode } from 'react';
22
import { Provider } from '../provider';
33

4-
export default function Layout({ params: { locale }, children }: { params: { locale: string }; children: ReactNode }) {
4+
export default async function Layout({
5+
params,
6+
children,
7+
}: {
8+
params: Promise<{ locale: string }>;
9+
children: ReactNode;
10+
}) {
11+
const { locale } = await params;
12+
513
return <Provider locale={locale}>{children}</Provider>;
614
}

examples/next-app/app/[locale]/page.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import { Provider } from './provider';
99
// }
1010

1111
// eslint-disable-next-line @typescript-eslint/no-unused-vars
12-
export default async function Home({ params: { locale } }: { params: { locale: string } }) {
12+
export default async function Home({ params }: { params: Promise<{ locale: string }> }) {
13+
const { locale } = await params;
14+
1315
// Uncomment to test Static Generation
1416
// setStaticParamsLocale(locale);
1517

examples/next-app/app/[locale]/subpage/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import { getI18n } from '../../../locales/server';
77
// }
88

99
// eslint-disable-next-line @typescript-eslint/no-unused-vars
10-
export default async function Subpage({ params: { locale } }: { params: { locale: string } }) {
10+
export default async function Subpage({ params }: { params: Promise<{ locale: string }> }) {
1111
// Uncomment to test Static Generation
12+
// const { locale } = await params;
1213
// setStaticParamsLocale(locale);
1314

1415
const t = await getI18n();

examples/next-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12-
"next": "^14.0.4",
12+
"next": "^15.0.0",
1313
"next-international": "workspace:*",
1414
"react": "^18.2.0",
1515
"react-dom": "^18.2.0"

examples/next-pages/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12-
"next": "^14.0.4",
12+
"next": "^15.0.0",
1313
"next-international": "workspace:*",
1414
"react": "^18.2.0",
1515
"react-dom": "^18.2.0"

packages/next-international/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "next-international",
3-
"version": "1.2.4",
3+
"version": "1.3.0",
44
"description": "Type-safe internationalization (i18n) for Next.js",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
@@ -50,7 +50,7 @@
5050
},
5151
"devDependencies": {
5252
"@types/react": "^18.2.45",
53-
"next": "^14.0.4",
53+
"next": "^15.0.0",
5454
"react": "^18.2.0",
5555
"tsup": "^8.0.1"
5656
},

0 commit comments

Comments
 (0)