Usage

Counterfact is three tools in one:

Choose the path that matches what you’re building, then dive deeper when you need a specific feature or workflow.


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 (contexts and shared store)Sharing in-memory state across routes and API groups
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 practical ways to use Counterfact for common API development and testing jobs.

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


Telemetry and privacy

Counterfact records startup options, hot-reload change categories (route/context/OpenAPI), and REPL command names. API file locations are hashed and command arguments are never sent.

Telemetry discussion


How it compares

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

How it compares