Vite (SPA)
No script needed - the provider applies the theme before first paint
A SPA has no server-rendered HTML to flash, so skip the script entirely:
import { ThemeProvider } from 'uni-themes'
import { createRoot } from 'react-dom/client'
import { App } from './app'
createRoot(document.getElementById('root')!).render(
<ThemeProvider>
<App />
</ThemeProvider>,
)The provider applies the theme synchronously on first subscribe, before the browser paints your app's first frame.
If you want the theme applied even before your bundle loads (e.g. a styled
loading screen in index.html), inline the script yourself:
import { buildThemeScript } from 'uni-themes/core'
// at build time, inject into index.html:
const script = `<script>${buildThemeScript()}</script>`The playground runs under StrictMode to prove the store survives double-rendering.