Skip to main content

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

ts-rest makes creating a fully typed API trivial - giving you more time to focus on what matters, your product and your project.

client.ts

const client = initClient(contract, {
baseUrl: 'http://localhost:3000',
baseHeaders: {},
});

const { body, status } = await client.createPost({
body: {
title: 'Post Title',
body: 'Post Body',
},
});
server.ts

const s = initServer();

const router = s.router(contract, {
createPost: async ({ body }) => {
const post = await prisma.post.create({
data: body,
});

return {
status: 201,
body: post,
};
},
});

createExpressEndpoints(contract, router, app);
🪄

RPC-like Client Without Codegen

Fully typed RPC-like client, with no need for code generation, reducing your bundle size as the types disappear at compile time.

🚀

API Design Agnostic

We don't abstract away from your API structure, we aim to let you use your API with other consumers as-is.

❤️

First Class DX

Less unnecessary builds in monorepos, instant compile-time errors, and instantly view endpoint implementations through your IDEs "go to definition"

✌️

Framework Agnostic

ts-rest comes with a whole host of support frameworks, including Express, Nest, Next and react-query!

What is this?

ts-rest was initially designed for TS-first teams, in legacy codebases, who are working towards improving stability and safety - who may have limited resources to migrate to a new solution/tech (such as GraphQL), and need a simple, safe API with a focus on DX and adoption speed.

  • A tiny type-safe wrapper around existing, battle-tested, established tech
  • An incrementally adoptable tool, for TS-first teams who care about stability + safety
  • No opinionated API structure, should be compatible with your existing structures
Ready to get started?