Skip to main content

Overview

Contract Kit is part of a growing ecosystem of TypeScript libraries that provide end-to-end type safety for APIs. This page compares Contract Kit with similar libraries to help you choose the right tool for your project.

Quick Comparison Table

FeatureContract KittRPCts-restHono RPCZodios
ProtocolRESTRPCRESTRPCREST
Type Safety✅ Full✅ Full✅ Full✅ Full✅ Full
Codegen❌ None❌ None❌ None❌ None❌ None
OpenAPI✅ Yes⚠️ Via plugin✅ Yes✅ Yes✅ Yes
Schema LibrariesStandard SchemaZod/Superstruct/YupZodZodZod
Architecture SupportHexagonal/CleanMVC/CustomMVC/CustomMVC/CustomMVC/Custom
Framework AdaptersNext.js (more coming)MultipleMultipleHono-nativeExpress/etc
React IntegrationOptional (@contract-kit/react-query)Built-inOptionalLimitedLimited
Dependency InjectionBuilt-in (Ports/Providers)CustomCustomCustomCustom

Detailed Comparisons

Contract Kit vs tRPC

Contract Kit is a better choice when:
  • You need RESTful APIs with proper HTTP semantics (methods, status codes, headers)
  • You want OpenAPI/Swagger documentation out of the box
  • You’re building with clean/hexagonal architecture patterns
  • You need flexibility to use any Standard Schema library (Zod, Valibot, ArkType, etc.)
  • You want built-in dependency injection with ports and providers
  • Your API needs to be consumed by non-TypeScript clients
Example: Building a public REST API that needs OpenAPI docs for external consumers.
tRPC is a better choice when:
  • You’re building a full-stack TypeScript application where client and server are always in the same monorepo
  • You prefer RPC-style APIs over REST
  • You need real-time subscriptions (tRPC has built-in WebSocket support)
  • You want the most mature ecosystem with extensive community plugins
  • You’re already using React Query heavily (tRPC integrates deeply with React Query)
Example: Building an internal admin dashboard where all clients are TypeScript.

Key Differences

API Style

Contract Kit: RESTful with proper HTTP methods, paths, and status codestRPC: RPC-style procedures (query/mutation) with custom protocol

OpenAPI

Contract Kit: Built-in OpenAPI generation from contractstRPC: Requires third-party plugins for OpenAPI support

Architecture

Contract Kit: Built-in hexagonal architecture with ports/providerstRPC: Flexible, but no opinionated architecture patterns

Schema Libraries

Contract Kit: Any Standard Schema library (Zod, Valibot, ArkType, etc.)tRPC: Zod, Superstruct, Yup, or custom validators

Contract Kit vs ts-rest

Contract Kit is a better choice when:
  • You want built-in architecture patterns (hexagonal/clean architecture)
  • You need dependency injection out of the box
  • You prefer a more opinionated framework that guides structure
  • You want integrated providers for common services (auth, mail, cache, etc.)
  • You need support for any Standard Schema library, not just Zod
Example: Building an enterprise application with complex business logic and multiple external dependencies.
ts-rest is a better choice when:
  • You want a minimal, unopinionated library you can integrate into any architecture
  • You need maximum framework flexibility (works with Express, Fastify, Nest.js, etc.)
  • You’re comfortable building your own architecture patterns
  • You only need Zod for validation
Example: Adding type-safe APIs to an existing Node.js application with established patterns.

Key Differences

Architecture

Contract Kit: Opinionated hexagonal architecture with built-in patternsts-rest: Minimal and unopinionated, fits into any architecture

Dependency Injection

Contract Kit: Built-in ports and providers systemts-rest: Bring your own DI solution

Framework Support

Contract Kit: Next.js (more adapters coming)ts-rest: Express, Fastify, Nest.js, Next.js, and more

Providers

Contract Kit: Pre-built providers for auth, mail, cache, etc.ts-rest: Build your own integrations

Contract Kit vs Hono RPC

Contract Kit is a better choice when:
  • You need RESTful APIs with proper REST semantics
  • You want hexagonal architecture support
  • You need Next.js integration specifically
  • You want built-in dependency injection and providers
  • You need support for multiple schema libraries
Example: Building a complex Next.js application with clean architecture.
Hono RPC is a better choice when:
  • You’re already using Hono as your web framework
  • You need edge runtime support (Cloudflare Workers, Deno, etc.)
  • You want maximum performance and minimal overhead
  • You prefer RPC-style APIs
Example: Building a high-performance edge API on Cloudflare Workers.

Key Differences

Framework

Contract Kit: Standalone with adapters (Next.js, etc.)Hono RPC: Built specifically for Hono framework

Runtime

Contract Kit: Node.js focused (Next.js)Hono RPC: Edge runtime optimized

API Style

Contract Kit: RESTful with HTTP methods and status codesHono RPC: RPC-style procedures

Architecture

Contract Kit: Opinionated hexagonal architectureHono RPC: Minimal, flexible patterns

Contract Kit vs Zodios

Contract Kit is a better choice when:
  • You want hexagonal architecture support
  • You need built-in dependency injection
  • You prefer Next.js integration
  • You want more than just contracts (application layer, ports, providers)
  • You need support for multiple schema libraries (not just Zod)
Example: Building a large-scale application with complex business logic.
Zodios is a better choice when:
  • You want a minimal contract-first library
  • You only need Express support
  • You’re already heavily invested in Zod
  • You want a mature, stable library
Example: Adding type-safe contracts to a simple Express API.

Key Differences

Scope

Contract Kit: Full framework with architecture patternsZodios: Focused library for contracts and validation

Framework Support

Contract Kit: Next.js (more coming)Zodios: Express-focused

Architecture

Contract Kit: Built-in hexagonal architectureZodios: No architectural opinions

Maturity

Contract Kit: Prototype/exploratory - APIs may change before 1.0Zodios: Stable and mature

What Makes Contract Kit Unique?

Contract Kit stands out in several key areas:

1. Hexagonal Architecture Built-In

Contract Kit is the only library with first-class support for clean/hexagonal architecture:
// Built-in ports and providers pattern
const ports = definePorts({
  db: databasePort,
  mail: mailPort,
  cache: cachePort,
});

// Dependency injection in every request
export const GET = server.route(contract).handle(async ({ ctx }) => {
  // ctx.ports gives you access to all dependencies
  await ctx.ports.mail.send({ to: "[email protected]" });
});

2. Standard Schema Support

Works with any Standard Schema library, giving you maximum flexibility:
import { z } from "zod";

const schema = z.object({ name: z.string() });

3. Optional Everything

Contract Kit is highly modular - use only what you need:
  • Core contracts without server/client
  • Server without React
  • React Query without React Hook Form
  • Providers individually (auth, mail, cache, etc.)

4. Pre-Built Providers

Save time with ready-to-use provider integrations:
  • Auth: Better Auth integration
  • Database: Drizzle + Turso
  • Cache: Redis, Upstash
  • Mail: Resend, SMTP
  • Jobs: Inngest
  • Rate Limiting: Upstash

Decision Guide

1

Choose your API style

  • Need REST APIs? → Contract Kit, ts-rest, or Zodios
  • Prefer RPC? → tRPC or Hono RPC
2

Consider your architecture

  • Want clean/hexagonal architecture? → Contract Kit
  • Need flexibility? → ts-rest, tRPC, Zodios
3

Evaluate framework compatibility

  • Using Next.js? → Contract Kit or ts-rest
  • Using Express? → ts-rest, Zodios
  • Using Hono? → Hono RPC
  • Need multiple frameworks? → ts-rest
4

Check ecosystem needs

  • Need dependency injection? → Contract Kit
  • Want pre-built providers? → Contract Kit
  • Need maximum maturity? → tRPC
  • Want edge runtime? → Hono RPC

Migration Paths

From tRPC

If you’re considering moving from tRPC to Contract Kit:
  • End-to-end type safety without codegen
  • Runtime validation with schema libraries
  • TypeScript inference for inputs and outputs
  • REST instead of RPC (proper HTTP methods and status codes)
  • Built-in OpenAPI generation
  • Hexagonal architecture patterns
  • Ports and providers for dependency injection
  • You’ll need to restructure from procedures to REST endpoints
  • OpenAPI docs will be automatically available
  • You can adopt clean architecture gradually
  • React Query integration is similar but separate package

From ts-rest

If you’re considering moving from ts-rest to Contract Kit:
  • Contract-first REST APIs
  • Type-safe clients and servers
  • OpenAPI generation support
  • Built-in hexagonal architecture
  • Ports and providers system
  • Opinionated structure (less flexibility)
  • Pre-built provider integrations
  • Contract definitions are very similar
  • You’ll gain architecture patterns and DI
  • Currently limited to Next.js (more adapters coming)
  • Pre-built providers save integration time

Acknowledgements

Contract Kit wouldn’t exist without the pioneering work of:
  • tRPC – for proving end-to-end type safety without codegen is possible and valuable
  • ts-rest – for demonstrating contract-first REST APIs work beautifully with TypeScript
  • Laravel – for showing that frameworks can be both elegant and powerful
We’re deeply grateful to these projects and their communities.

Next Steps