Skip to content

chore: Update App Router example to use NextIntlClientProvider #1060

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading