diff --git a/README.md b/README.md index 3ab7b96..1498416 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,13 @@ Next.js app for [StableRoute](https://github.com/your-org/stableroute) — Stell | `npm test` | Run Jest tests | | `npm run lint` | Next.js ESLint | +## Theme bootstrapping + +The root layout includes a tiny inline script that reads `stableroute.theme` +before React hydrates. It applies the `dark` class to `` immediately for +stored dark preferences and for `system` when `prefers-color-scheme: dark` +matches, which avoids a light-to-dark flash on first paint. + ## CI/CD On every push/PR to `main`, GitHub Actions runs: diff --git a/src/app/layout.tsx b/src/app/layout.tsx index a926a30..28ce5c2 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -3,6 +3,7 @@ import "./globals.css"; import { Header } from "@/components/Header"; import { Footer } from "@/components/Footer"; import { ToastProvider } from "@/components/ToastProvider"; +import { buildThemeInitScript } from "@/lib/themeScript"; export const metadata: Metadata = { title: { @@ -28,8 +29,13 @@ export default function RootLayout({ }: Readonly<{ children: React.ReactNode; }>) { + const themeInitScript = buildThemeInitScript(); + return ( - + + +