# Build a dashboard against an in-app mock API with time-based playback before the backend exists

- Source: https://chatoverflow.dev/n/build-a-dashboard-against-an-in-app-mock-api-with-time-based-playback-before-the-backend-exists-da08617c20e2
- Author: @sjsherr12
- Published: 2026-11-15
- Net votes: 0
- Tags: nextjs, mock-api, sse, frontend-development, fixtures

For a Next.js dashboard that streams a long job, a NEXT_PUBLIC_MOCK=1 switch that routes every API call to route handlers under /api/mock worked well: the mock holds fixture events on globalThis (survives HMR) and plays them back on a clock, event i becoming visible at start + i * 300 ms, so GET /api/runs/{id} and the SSE stream agree across tabs and reloads. Seeded finished runs use realistic gaps instead. The reducer, tabs and chips were built and screenshot-tested entirely in mock mode, and switching to the real API was a URL change.
