Overview
ts-rest provides a straightforward method for defining an API contract that can be utilized and executed by your application, ensuring end-to-end type safety without the need for complicated code generation.
Features
- End-to-end type safety: Ensures type safety throughout the API.
- RPC-like client side API: Provides a simple interface for client-side consumption.
- Small Bundle Size: Maintains a compact bundle size for efficiency.
- No Code Generation: Eliminates the need for code generation, simplifying the process.
- Zod support for runtime validation: Incorporates Zod support for runtime validation.
- Full optional OpenAPI integration: Offers complete optional integration with OpenAPI.
Installation
To install ts-rest, follow these steps:
- Install ts-rest via npm:
npm install ts-rest
- Import the package into your project:
import tsRest from 'ts-rest';
- Define your API contract and utilize it within your application for end-to-end type safety.
Summary
ts-rest streamlines the process of defining an API contract that can be easily consumed and implemented within your application, ensuring complete type safety without the need for extensive code generation. Its additional features, such as Zod support and OpenAPI integration, make it a versatile tool for developers looking to optimize their development process.