Skip to content

Commit

Permalink
chore(docs): add snippet when not using Next.js 15
Browse files Browse the repository at this point in the history
  • Loading branch information
QuiiBz committed Oct 28, 2024
1 parent cb9e087 commit 603ce0c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/pages/docs/app-setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ Move all your routes inside an `app/[locale]/` folder. For Client Components, wr
import { ReactElement } from 'react'
import { I18nProviderClient } from '../../locales/client'

// If you are using Next.js < 15, you don't need to await `params`:
// export default function SubLayout({ params: { locale }, children }: { params: { locale: string }, children: ReactElement }) {
export default function SubLayout({ params, children }: { params: Promise<{ locale: string }>, children: ReactElement }) {
const { locale } = await params

Expand Down
2 changes: 2 additions & 0 deletions docs/pages/docs/app-static-rendering.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Inside all pages that you want to be statically rendered, call this `setStaticPa
// app/[locale]/page.tsx and any other page
import { setStaticParamsLocale } from 'next-international/server'

// If you are using Next.js < 15, you don't need to await `params`:
// export default function Page({ params: { locale } }: { params: { locale: string } }) {
export default function Page({ params }: { params: Promise<{ locale: string }> }) {
const { locale } = await params
setStaticParamsLocale(locale)
Expand Down
6 changes: 6 additions & 0 deletions docs/pages/docs/rtl-support.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ If you want to support the `dir` attribute in your `<html>` tag, you'll need to

```tsx {3,6}
// app/[locale]/layout.tsx

// If you are using Next.js < 15, you don't need to await `params`:
// export default function Layout({ children, params: { locale } }: { children: ReactElement, params: { locale: string } }) {
export default function Layout({ children, params }: { children: ReactElement, params: Promise<{ locale: string }> }) {
const { locale } = await params
const dir = new Intl.Locale(locale).getTextInfo().direction

return (
Expand Down Expand Up @@ -56,6 +60,8 @@ Then, use it instead of the native `Intl.Locale.prototype.getTextInfo` API:
// app/[locale]/layout.tsx
import Locale from 'intl-locale-textinfo-polyfill'

// If you are using Next.js < 15, you don't need to await `params`:
// export default function Layout({ children, params: { locale } }: { children: ReactElement, params: { locale: string } }) {
export default function Layout({ children, params }: { children: ReactElement, params: Promise<{ locale: string }> }) {
const { locale } = await params
const { direction: dir } = new Locale(locale).textInfo
Expand Down

0 comments on commit 603ce0c

Please sign in to comment.