Skip to content

Commit 0a19357

Browse files
authored
chore: Update App Router example to use NextIntlClientProvider (#1060)
1 parent 748b6dd commit 0a19357

File tree

1 file changed

+14
-3
lines changed
  • examples/example-app-router/src/app/[locale]

1 file changed

+14
-3
lines changed

examples/example-app-router/src/app/[locale]/layout.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import clsx from 'clsx';
22
import {Inter} from 'next/font/google';
3-
import {getTranslations, unstable_setRequestLocale} from 'next-intl/server';
3+
import {NextIntlClientProvider} from 'next-intl';
4+
import {
5+
getMessages,
6+
getTranslations,
7+
unstable_setRequestLocale
8+
} from 'next-intl/server';
49
import {ReactNode} from 'react';
510
import Navigation from '@/components/Navigation';
611
import {locales} from '@/config';
@@ -33,11 +38,17 @@ export default async function LocaleLayout({
3338
// Enable static rendering
3439
unstable_setRequestLocale(locale);
3540

41+
// Providing all messages to the client
42+
// side is the easiest way to get started
43+
const messages = await getMessages();
44+
3645
return (
3746
<html className="h-full" lang={locale}>
3847
<body className={clsx(inter.className, 'flex h-full flex-col')}>
39-
<Navigation />
40-
{children}
48+
<NextIntlClientProvider messages={messages}>
49+
<Navigation />
50+
{children}
51+
</NextIntlClientProvider>
4152
</body>
4253
</html>
4354
);

0 commit comments

Comments
 (0)