Skip to content
RPC
Language:en Author:AtomForge
typescript rpc web-development

Rpc — Type-safe APIs with TypeScript

Rpc is a full-stack RPC (Remote Procedure Call) framework for TypeScript. Define an API on the server and share its type with the client to get autocompletion and end-to-end type checking, without sharing server implementations with the browser.

The framework uses standard Web API Request and Response objects. It works with SvelteKit, Next.js, Nuxt, Express, Hono, and compatible Node.js or edge runtimes. MessagePack is the primary transport, with JSON support and multipart file uploads.

The central idea is to keep the API contract close to its implementation. A nested server object becomes the shape of the client: related endpoints can live under groups such as posts, and callers use those same names rather than assembling endpoint URLs themselves. The shared contract is a TypeScript type, while the actual call still crosses an HTTP boundary.

Who this book is for

This book is for TypeScript developers integrating Rpc into an application. Familiarity with async functions, HTTP, and your chosen web framework is helpful. The chapters adapt the project's English documentation into a self-contained BookMD book.

Reading guide

  1. Getting started: install the package and connect a server API to a typed client.
  2. Server-side usage: define endpoints, validate input, customize context, handle errors, and apply middleware.
  3. Client-side usage: call endpoints, narrow response types, upload files, and test handlers without an HTTP server.
  4. Framework adapters: connect the handler to your application's request lifecycle.
  5. Communication protocol: understand request encoding and response negotiation.

You can read the chapters in order or go directly to the topic needed for your integration.

For a first integration, start with one read endpoint and one command, then connect them through the adapter for your framework. Once that round trip works, add validation and authorization before expanding the API. The protocol chapter is most useful when inspecting requests, integrating a non-Rpc client, or diagnosing an encoding mismatch.