Counterfact is three tools in one:
- a code generator that converts an OpenAPI document to TypeScript route files
- a mock server optimized for front-end development workflows
- a live REPL for inspecting and manipulating server state at runtime
This page is your map to the documentation.
New to Counterfact? Begin with the Getting Started guide for a step-by-step walkthrough.
| Feature | Description |
|---|---|
| Generated code | How Counterfact generates TypeScript from your OpenAPI spec |
| Routes | Writing route handlers, building responses, reading request data |
| State (context objects) | Sharing in-memory state across routes |
| Hot reload | Live file updates without restarting the server |
| REPL | Interactive terminal for runtime inspection and control |
| Proxy | Mix real backend calls with mocked endpoints |
| Middleware | Cross-cutting request/response logic |
| TypeScript native mode | Run route files directly without a compilation step |
| Programmatic API | Embed Counterfact in test suites with Playwright, Cypress, etc. |
| Without OpenAPI | Use Counterfact without an OpenAPI document |
Patterns are reusable solutions to recurring problems when building API simulations.
See the patterns index for the full list.
Complete technical reference: the $ parameter API, CLI flags, architecture overview, and more.
Common questions about state, types, hot reload, code generation, and regeneration.
→ FAQ
Side-by-side comparison with json-server, WireMock, Prism, Microcks, and MSW.