Skip to main content

Function: getThemeScriptContent()

getThemeScriptContent(config): string

Defined in: ssrScript.ts:46

Returns self-contained JavaScript code that prevents theme flash on SSR/SSG.

Insert the returned string into an inline <script> tag in the <head>, before any stylesheets or the app bundle.

Parameters

config

ThemeScriptConfig = {}

Returns

string

Example

// Next.js app/layout.tsx
import { getThemeScriptContent } from '@ttoss/theme2';

export default function RootLayout({ children }) {
return (
<html lang="en">
<head>
<script dangerouslySetInnerHTML={{ __html: getThemeScriptContent() }} />
</head>
<body>{children}</body>
</html>
);
}