A production-style demo project for the talk "MSW Beyond Tests: Develop Frontend Without Waiting for Backend".
This repo shows how to build frontend features without blocking on backend readiness, while still preserving a real integration path.
👨🏫 Davit Hunanyan – MSW Beyond Tests: Develop Frontend Without Waiting for Backend Frontend teams are often blocked by unstable environments, missing endpoints, or shifting API contracts. In this talk, Dhunanyan shares a practical case study of building a real-world Next.js dashboard with runtime switching between MSW Intercept and Bypass to Real API. You’ll see how to keep shipping UI when backend is unavailable, simulate realistic failure scenarios on demand, and still preserve an honest integration path. Expect a live demo, architecture patterns you can adopt quickly, and concrete guidance for making frontend delivery faster, safer, and more predictable.
- Unblock frontend development when backend is down or not ready.
- Switch between mocked and real networking at runtime.
- Keep Local API and Backend API aligned with one shared real data source.
- Make runtime state visible with clear warning UX.
- Runtime switch:
MSW InterceptvsBypass to Real API - Runtime target:
Local API (/api)vsBackend Endpoint - Scenario-driven behavior simulation (in MSW mode)
- Manual refresh flow for explicit transitions
- Shared real dataset for Local API + Node backend:
db/dashboard.json
Browser UI (Next.js App Router)
-> Data Source switch:
1) MSW Intercept
2) Bypass to Real API
Real API target switch:
A) Local API routes (/api/*)
B) Node API server (localhost:8787)
Real data source for A + B:
db/dashboard.json
- Next.js App Router
- React 19
- TypeScript
- MSW (browser worker)
- Node.js HTTP server (
tsx)
app/- Next.js app and local API routescomponents/- dashboard and UI componentscontext/- MSW provider/contextmocks/- MSW worker + handlersserver/- standalone Node API + swagger pagedb/dashboard.json- shared real data seedutils/dashboard-db.ts- DB clone + summary recompute helperspresentation/- talk deck and speaker materials
yarnRun client + Node API together:
yarn devRun only Next.js client (http://localhost:3000):
yarn dev:clientRun only Node API server (http://localhost:8787/swagger):
yarn dev:serverForce-disable MSW in client:
yarn dev:client:no-mockProduction build (client):
yarn build
yarn startGET /healthzGET /readyzGET /versionGET /openapi.jsonGET /swagger(controlled bySERVER_SWAGGER_ENABLED)
Copy env.example and set as needed:
NEXT_PUBLIC_API_BASE_URL- backend base URL for clientNEXT_PUBLIC_API_MOCKING-enabledordisabledNEXT_PUBLIC_APP_URL- canonical app URL for metadataNEXT_PUBLIC_ALLOW_INDEXING-falserecommended for nonprodNEXT_PUBLIC_APP_ENV-development,nonprod, etc.APP_NAMEAPP_ENVAPP_VERSIONSERVER_HOSTSERVER_PORTSERVER_CORS_ORIGINSERVER_SWAGGER_ENABLED
- Start with Backend Endpoint + Bypass to Real API
- Stop backend server and show backend-unreachable warning
- Switch to MSW Intercept and continue working
- Show scenarios (
server-500,network-error,partial-data, etc.) - Return to Bypass mode to validate real path
- Main deck: gp_msw_beyond_tests.pptx
- Slides source:
presentation/slides.md - Speaker script:
presentation/speach.md
Please read:
.github/CONTRIBUTING.md.github/CODE_OF_CONDUCT.md.github/SECURITY.md
MIT - see LICENSE.
