Skip to content
On this page

Server-Side Rendering

Nano Stores support SSR. Use standard strategies.

if (isServer) {
$settings.set(initialSettings)
$router.open(renderingPageURL)
}

You can wait for async operations (for instance, data loading via isomorphic fetch()) before rendering the page:

import { allTasks } from 'nanostores'
$post.listen(() => {}) // Move store to active mode to start data loading
await allTasks()
const html = ReactDOMServer.renderToString(<App />)

Imported from the Nano Stores README for version 1.5.5. Improve this page there.