Skip to main content


RPC-like client and server helpers for a magical end to end typed experience

langue typescriptGithub Workflow StatusnpmLicenseBundle SizeDiscord


ts-rest offers a simple way to define a contract for your API, which can be both consumed and implemented by your application, giving you end to end type safety without the hassle or code generation.


  • End to end type safety ๐Ÿ›Ÿ
  • RPC-like client side interface ๐Ÿ“ก
  • Tiny bundle size ๐ŸŒŸ (1kb!)
  • Well-tested and production ready โœ…
  • No Code Generation ๐Ÿƒโ€โ™€๏ธ
  • Zod support for runtime type checks ๐Ÿ‘ฎโ€โ™€๏ธ
  • Full optional OpenAPI integration ๐Ÿ“

Super Simple Exampleโ€‹

Easily define your API contract somewhere shared

const contract = c.contract({
getPosts: {
method: 'GET',
path: '/posts',
query: z.object({
skip: z.number(),
take: z.number(),
}), // <-- Zod schema
responses: {
200: c.response<Post[]>(), // <-- OR normal TS types

Fulfil the contract on your sever, with a type-safe router:

const router = s.router(contract, {
getPost: async ({ params: { id } }) => {
return {
status: 200,
body:{ where: { id } }),

Consume the api on the client with a RPC-like interface:

const result = await client.getPosts({
query: { skip: 0, take: 10 },
// ^-- Fully typed!


Install the core package

yarn add @ts-rest/core
# Optional react-query integration
yarn add @ts-rest/react-query
# Pick your backend
yarn add @ts-rest/nest @ts-rest/express
# For automatic server OpenAPI gen
yarn add @ts-rest/open-api

Create a contract, implement it on your server then consume it in your client. Incrementally adopt, trial it with your team, then get shipping faster.

๐Ÿ‘‰ Read more on the official Quickstart Guide๐Ÿ‘ˆ

Star Historyโ€‹

Star History Chart

Contributors โœจโ€‹

Thanks goes to these wonderful people (emoji key):

Youssef Gaber
Youssef Gaber

๐Ÿ’ป ๐Ÿค” โš ๏ธ
Per Hermansson
Per Hermansson

๐Ÿ“– ๐Ÿ’ป
Grรฉgory Houllier
Grรฉgory Houllier

Michael Angelo
Michael Angelo

Pieter Venter
Pieter Venter

Rifaldhi AW
Rifaldhi AW


This project follows the all-contributors specification. Contributions of any kind welcome!

Powered by Vercel