BASE

tRPC

tRPC

Backend / API library · Free

Connects a TypeScript client and server through typed procedures without manually duplicating API types or generating a REST client.

Also known as: trpc/trpc; trpc; end-to-end-typesafe-apis

Resource illustration: tRPC

Open resource ↗

What you can use for free

Code and local use under MIT.

Paid features and costs

Compute, your own hosting, and external services are paid for separately if selected.

Access and limitations

Code and local use under MIT. Compute, your own hosting, and external services are paid for separately if selected.

Use cases

  • Connect a TypeScript frontend to a typed backend
  • Call a procedure from the client and handle a typed result/error

Example workflow

A possible workflow; this is not a report of hands-on testing.

Connect a TypeScript frontend to a typed backend.

Before you start

  • A data contract or HTTP workflow.
  • A project with a supported runtime.

Steps

  1. Define a procedure and its input schema on the server.
  2. Call a procedure from the client and handle a typed result/error.
  3. Add error handling and an integration check of the result.

Check your result

  • Invalid and missing data are handled predictably.
  • Types and the actual response agree; errors are not hidden.

Choosing tRPC

Connect a TypeScript frontend to a typed backend

Choose this when

  • Connect a TypeScript frontend to a typed backend
  • Call a procedure from the client and handle a typed result/error

Requirements

  • A validator can use a supported schema library or a custom function throwing an error for an invalid value.

Things to consider

  • Costs and limits of free use: Compute, your own hosting, and external services are paid for separately if selected.
  • Terms of use: MIT: code; dependencies have separate licenses.
  • Consecutive .input() calls merge only objects. A repeated property is replaced by the later validator's value; this should not be interpreted as arbitrary merging of arrays or primitives.

Frequently asked questions

What can you use for free in tRPC?

Code and local use under MIT.

What additional costs might arise with tRPC?

Compute, your own hosting, and external services are paid for separately if selected.

What terms of use matter for tRPC?

MIT: code; dependencies have separate licenses.

How do you get started with tRPC?

Define a procedure and its input schema on the server. Call a procedure from the client and handle a typed result/error. Add error handling and an integration check of the result.

Does tRPC typing replace incoming data validation?

The client obtains types from server declarations without importing executable server code. Runtime data validation is specified separately: .input() checks input and .output() checks the result; an output validation failure returns INTERNAL_SERVER_ERROR.

License

MIT: code; dependencies have separate licenses.

MIT — permissive license

You can use, modify, distribute, and sell the code, including in a closed-source commercial product. When sharing copies or substantial portions of the code, retain the license text and copyright notice. You do not need to open-source your entire project; the author provides no warranties.

License terms

Technologies and topics

  • tRPC
  • API
  • Development

Sources

Other resources