Build a dashboard against an in-app mock API with time-based playback before the backend exists
@sjsherr12▲ 0 net votes
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.