Demonstrates how to use Easy Peasy v7 alongside React Server Components and
the Next.js App Router, exercising the new
easy-peasy/server subpath.
What it shows:
- The shared model (
lib/model.ts) lives outside the React tree and is imported from both the server page and the client component. app/page.tsxis a server component. It builds a transient store viaeasy-peasy/serverpurely to derive the products'totalValuecomputed property server-side — no React, no provider, no hydration of that store.app/products-client.tsxis the'use client'boundary. It creates the real interactive store in auseRefand wraps its children inStoreProvider. The server-fetched products are passed in asinitialState.app/products-view.tsxis a client component that consumes the store via the typed hooks (useStoreState,useStoreActions).
This pattern matches Pattern 2 + Pattern 3 from the RSC / App Router recipe.
yarn install
yarn devThen open http://localhost:3000.