Skip to content

Introduction

yRest is a zero-config REST API mock server for frontend developers. It reads a db.yml file and automatically exposes a full CRUD REST API — including relations, query parameters, pagination, SSE streams and custom static routes — with no backend needed.

Terminal window
npx @yrest/cli serve db.yml
# → REST API at http://localhost:3070

For a version-by-version history of what’s been added and what’s on the roadmap, see the Changelog and Releases on GitHub.

  • You’re building a frontend and need a realistic API before the backend is ready.
  • You need a predictable mock for integration tests (Vitest, Playwright, Cypress).
  • You want to demo a UI flow without maintaining a real server.
  • You need SSE or custom endpoint behaviour that json-server can’t handle.
  • You’re designing a new API contract before the backend team starts building — yRest gives you a real running server to validate the exact shape, not just a static spec document.
  • You need to test error states, conditional auth flows, or network latency — simulate them with conditional scenarios and delay injection, no server code required.

Both yRest and json-server share the same zero-config philosophy — point them at a data file and get a REST API instantly. The difference is how far each one goes. yRest extends the model with a richer relation system, typed query operators, SSE streams, conditional mock scenarios, and a full programmatic API. If json-server covers your needs, keep using it. If you’ve hit its limits, yRest is the next step.

FeatureyRestjson-server
Foundation
Zero config
Full CRUD
YAML database
Query & Filtering
Field operators (_gte, _like, _regex…)
Field projection (_fields)
Pageable mode (envelope response)
Relations
Relations: many2one, one2one, many2many
Auto-embedding (_nested: true)
Mock features
Custom routes (_routes)
Template variables ({{}params.id}})
Conditional scenarios
Handler functions (JS logic)
SSE stream routes
Snapshot endpoints
Integration & tooling
Programmatic API for test frameworks
OpenAPI 3.0 export
TypeScript types

yRest can be used in two ways depending on your workflow.

As a dev-server — run it with npx alongside your frontend app, no installation required. See Quick Start for a step-by-step walkthrough.

Terminal window
npx @yrest/cli serve db.yml # zero-install, API ready at http://localhost:3070

Or install it as a dev dependency to skip the npx download on every run:

Terminal window
npm install -D @yrest/cli
npx @yrest/cli init # scaffold db.yml + yrest.config.yml
npx @yrest/cli serve db.yml

As a programmatic test fixture — import createYrestServer directly into your Vitest, Playwright or Cypress suite. No separate process, no CLI. See Programmatic API for the full API reference.

import { createYrestServer } from "@yrest/cli";
const server = createYrestServer({ file: "./tests/db.yml", port: 3070 });
await server.start();
// run tests ...
await server.stop();