Skip to content

Commit 7675c77

Browse files
committed
feat(demo): add use client example to next demo
1 parent a1c52c8 commit 7675c77

4 files changed

Lines changed: 22 additions & 6 deletions

File tree

demo/next/next.config.mjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import compiler from '@replexica/compiler';
22

3-
console.log(compiler);
4-
53
/** @type {import('next').NextConfig} */
64
const nextConfig = {};
75

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use client';
2+
3+
export default function ClientContent() {
4+
return (
5+
<div>
6+
Hello world!
7+
</div>
8+
);
9+
}

demo/next/src/app/client/page.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import ClientContent from "./content";
2+
3+
export default ClientContent;

demo/next/src/app/layout.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import type { Metadata } from "next";
22
import { Inter } from "next/font/google";
3+
import { ReplexicaIntlProvider } from '@replexica/react/client';
4+
import { loadLocaleFromCookie } from '@replexica/react/next';
35
import "./globals.css";
46

57
const inter = Inter({ subsets: ["latin"] });
@@ -9,14 +11,18 @@ export const metadata: Metadata = {
911
description: "Generated by create next app",
1012
};
1113

12-
export default function RootLayout({
14+
export default async function RootLayout({
1315
children,
1416
}: Readonly<{
1517
children: React.ReactNode;
1618
}>) {
19+
const locale = await loadLocaleFromCookie();
20+
const localeData = await import(`@replexica/output/${locale}.json`).then((m) => m.default);
1721
return (
18-
<html lang="en">
19-
<body className={inter.className}>{children}</body>
20-
</html>
22+
<ReplexicaIntlProvider data={localeData}>
23+
<html lang={locale}>
24+
<body className={inter.className}>{children}</body>
25+
</html>
26+
</ReplexicaIntlProvider>
2127
);
2228
}

0 commit comments

Comments
 (0)