Server-side rendering with store hydration
{
"name": "Server User 603",
"age": 28,
"email": "server-user-603@example.com"
}{
"userId": "603",
"lastLogin": "2025-09-16T13:02:10.968Z",
"serverLoadTime": "2025-09-16T13:02:10.968Z",
"renderTime": "2025-09-16T13:02:10.968Z"
}✅ This data was fetched on the server and rendered as part of the initial HTML. The store was initialized with this data before sending to the client.
Waiting for client-side hydration to complete
Name: Alice
Age: 25
Email: alice@example.com
Render Count: 0
This component is now fully reactive!
Buttons will be enabled after hydration completes
{
"name": "Server User 603",
"age": 28,
"email": "server-user-603@example.com"
}{
"name": "Alice",
"age": 25,
"email": "alice@example.com"
}initializeServerStore() returns serializable stateuserStore.hydrate() updates client storeinitializeServerStore() populates the storeexport default async function SSRDemoPage() {
// Fetch data on server
const userData = await fetchUserData(userId);
// Initialize store with server data
const serverState = initializeServerStore(userStore, {
name: userData.name,
age: userData.age,
email: userData.email,
});
return (
<div>
<h1>Server-rendered: {userData.name}</h1>
<SSRUserProfile serverState={serverState} />
</div>
);
}"use client";
import { useEffect } from "react";
export default function SSRUserProfile({ serverState }) {
// Hydrate client store with server state
useEffect(() => {
if (serverState) {
userStore.hydrate(serverState);
}
}, [serverState]);
const user = userStore.useStore();
return (
<div>
<p>Name: {user.name}</p>
<p>Age: {user.age}</p>
{/* Fully reactive now! */}
</div>
);
}