worried-planet-2191
02/21/2025, 11:45 PMfresh-football-47124
better-terabyte-3391
02/22/2025, 12:16 PMexport const runtime = 'edge';
export default async function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
configureServerSideGrowthBook();
// Create and initialize a GrowthBook instance
const gb = new GrowthBook({
apiHost: process.env.NEXT_PUBLIC_GROWTHBOOK_API_HOST,
clientKey: process.env.NEXT_PUBLIC_GROWTHBOOK_CLIENT_KEY,
});
await gb.init({timeout: 1000});
const cookie = await cookies();
// Set targeting attributes for the user
// TODO: get from cookies/headers/db
await gb.setAttributes({
id: cookie.get(GB_UUID_COOKIE)?.value || "",
});
// Get the payload to hydrate the client-side GrowthBook instance
// We need the decrypted payload so the initial client-render can be synchronous
const payload = gb.getDecryptedPayload();
// If the above features ran any experiments, get the tracking call data
// This is passed into the GrowthBookTracking client component below
const trackingData = gb.getDeferredTrackingCalls();
// Cleanup your GrowthBook instance
gb.destroy();
return (
html lang="en"
head
meta name="viewport" content="width=device-width, initial-scale=1"/
meta name="next-size-adjust" content=""/
<link
href="/images/favicon-32x32.png"
rel="shortcut icon" type="image/x-icon"/>
/head
body
div className="flex flex-col min-h-screen"
ClientApp payload={payload}
{children}
/ClientApp
GrowthBookTracking data={trackingData}/
Footer/
/div
/body
/html
);
}better-terabyte-3391
02/22/2025, 12:17 PMbetter-terabyte-3391
02/22/2025, 12:18 PMbetter-terabyte-3391
02/22/2025, 12:20 PMbetter-terabyte-3391
02/22/2025, 12:20 PMbetter-terabyte-3391
02/22/2025, 5:12 PMhybrite Example on Cloudflare Pages.fresh-football-47124