Usage

Counterfact is three tools in one:

This page is your map to the documentation.


Getting started

New to Counterfact? Begin with the Getting Started guide for a step-by-step walkthrough.


Features

FeatureDescription
Generated codeHow Counterfact generates TypeScript from your OpenAPI spec
RoutesWriting route handlers, building responses, reading request data
State (context objects)Sharing in-memory state across routes
Hot reloadLive file updates without restarting the server
REPLInteractive terminal for runtime inspection and control
ProxyMix real backend calls with mocked endpoints
MiddlewareCross-cutting request/response logic
TypeScript native modeRun route files directly without a compilation step
Programmatic APIEmbed Counterfact in test suites with Playwright, Cypress, etc.
Without OpenAPIUse Counterfact without an OpenAPI document
Multiple versionsServe multiple API versions simultaneously from a single process

Patterns

Patterns are reusable solutions to recurring problems when building API simulations.

See the patterns index for the full list.


Reference

Complete technical reference: the $ parameter API, CLI flags, architecture overview, and more.

Reference


FAQ

Common questions about state, types, hot reload, code generation, and regeneration.

FAQ


How it compares

Side-by-side comparison with json-server, WireMock, Prism, Microcks, and MSW.

How it compares