# ts-rest/ts-rest

RPC-like client, contract, and server implementation for a pure REST API

Repository: https://github.com/ts-rest/ts-rest
Canonical: https://ross.abutalabs.com/products/ts-rest
Homepage: https://ts-rest.com
Language: TypeScript
License: MIT
License Family: permissive
Topics: rpc, typescript, api, openapi, rest, fastify, nestjs, nextjs, react, react-query, solid
Last push: 2026-02-06T20:47:21+00:00

## Health v2 (maintenance only)
Score: 64/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 66, release rhythm 40, longevity 100
- inputs: {"age_days": 1502, "days_push": 208, "days_rel": 547, "gap_med": 11.0, "n_releases_24m": 3}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 3334, forks 178 (observed 2026-08-28T04:07:56.709635+00:00)

## What it is
ts-rest is a TypeScript library for defining a shared API contract that both client and server consume, providing end-to-end type safety for REST APIs without code generation. It supports Zod and other Standard Schema validation libraries, optional OpenAPI generation, and integrations with NestJS, Next.js, Express, Fastify, and React Query.

## Use cases
- add end-to-end type safety to a REST API between frontend and backend
- share an API contract between client and server in a monorepo
- generate OpenAPI specs from a typed API definition
- build a type-safe API client without code generation
- validate request and response bodies at runtime with Zod
- replace tRPC when a REST API or separate contract package is needed
- integrate typed API calls with React Query

## When to choose
- you want tRPC-like type safety but must keep a plain REST/HTTP API
- you need a separately publishable API contract shared across teams or packages
- you use NestJS, Next.js, Express, or Fastify and want typed routers
- you want OpenAPI documentation generated from your contract
- you want incremental adoption of type safety in an existing codebase

## When to avoid
- your client and server live in a single Next.js or Express app where tRPC is simpler
- your API consumers are third parties who cannot use TypeScript
- you need a non-REST protocol like gRPC or GraphQL
- your stack is not TypeScript

## Facets
- artifact type: library
- maturity: active
- function: rpc, http-client, http-server, api-framework, middleware, routing, serialization, api-documentation
- domain: web-development, backend, frontend, apis, developer-tools
- platform: cross-platform
- tags: end-to-end-type-safety, api-contract, zod, openapi, trpc-alternative, rest-client, react-query, nestjs, nextjs, fastify, standard-schema, nodejs, typescript, web-server

## Member repositories
- ts-rest/ts-rest (main) score 64

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:07:56.709635+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T18:41:27.969342+00:00, confidence not recorded.
  - readme: https://github.com/ts-rest/ts-rest (fetched 2026-08-28T04:07:56.709635+00:00, sha d6636705bfc7)
  - homepage: https://ts-rest.com (fetched 2026-08-29T09:34:48.419174+00:00, sha 786e7f56265e)
  - site_page: https://ts-rest.com/quickstart (fetched 2026-08-29T09:34:48.429524+00:00, sha 8fbba1068318)
  - site_page: https://ts-rest.com/changelog (fetched 2026-08-29T09:34:48.431792+00:00, sha 9d1a8f2eddd1)
  - site_page: https://ts-rest.com/faq (fetched 2026-08-29T09:34:48.434472+00:00, sha fc02534f3d02)
- Data as of 2026-08-30T08:39:29.467469+00:00.
