Skip to content

Commit

Permalink
chore: Update App Router example to use NextIntlClientProvider (#1060)
Browse files Browse the repository at this point in the history
  • Loading branch information
amannn committed May 8, 2024
1 parent 748b6dd commit 0a19357
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions examples/example-app-router/src/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import clsx from 'clsx';
import {Inter} from 'next/font/google';
import {getTranslations, unstable_setRequestLocale} from 'next-intl/server';
import {NextIntlClientProvider} from 'next-intl';
import {
getMessages,
getTranslations,
unstable_setRequestLocale
} from 'next-intl/server';
import {ReactNode} from 'react';
import Navigation from '@/components/Navigation';
import {locales} from '@/config';
Expand Down Expand Up @@ -33,11 +38,17 @@ export default async function LocaleLayout({
// Enable static rendering
unstable_setRequestLocale(locale);

// Providing all messages to the client
// side is the easiest way to get started
const messages = await getMessages();

return (
<html className="h-full" lang={locale}>
<body className={clsx(inter.className, 'flex h-full flex-col')}>
<Navigation />
{children}
<NextIntlClientProvider messages={messages}>
<Navigation />
{children}
</NextIntlClientProvider>
</body>
</html>
);
Expand Down

0 comments on commit 0a19357

Please sign in to comment.