feat: implement DynamicProviders to disable SSR for global context providers in root layout

This commit is contained in:
2026-05-06 20:47:29 +02:00
parent 19b405d9f2
commit bb464cf1c5
2 changed files with 18 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
import React from 'react';
import nextDynamic from 'next/dynamic'; // <-- 1. On importe l'outil dynamique
import { DynamicProviders } from '../components/DynamicProviders';
import Navbar from '../components/Navbar';
import Footer from '../components/Footer';
import { getSiteSettings } from '../lib/settings';
@@ -7,8 +7,7 @@ import { Metadata } from 'next';
import { Inter, Playfair_Display } from 'next/font/google';
import './globals.css';
// 2. LA MAGIE EST ICI : On force Next.js a ignorer les Providers pendant le build serveur
const Providers = nextDynamic(() => import('../components/Providers').then((mod) => mod.Providers), { ssr: false });
// 2. LA MAGIE EST ICI : On utilise un wrapper Client pour le no-SSR
const inter = Inter({
@@ -57,13 +56,13 @@ export default async function RootLayout({ children }: { children: React.ReactNo
return (
<html lang="fr" className={`${inter.variable} ${playfair.variable}`} style={devBrandOverride} suppressHydrationWarning>
<body className="bg-gray-50 text-gray-900 antialiased min-h-screen flex flex-col font-sans" suppressHydrationWarning>
<Providers>
<DynamicProviders>
<Navbar settings={settings} />
<main className="flex-grow">
{children}
</main>
<Footer settings={settings} />
</Providers>
</DynamicProviders>
</body>
</html>
);