API Layer & RPC
API frameworks and protocols compared — type-safe RPC, GraphQL, lightweight HTTP, and OpenAPI REST.
alternatives (4)
★ tRPC
Best for: Type-safe full-stack TS
End-to-end typesafe APIs for TypeScript — define procedures on the server, call them from the client with full inference.
- +Full type inference
- +No code gen
- +Great DX
- −TypeScript monorepo only
Apollo GraphQL
Best for: GraphQL APIs
GraphQL client and server ecosystem — schema-first APIs, caching, subscriptions, and a mature tooling stack.
- +Mature GraphQL
- +Client cache
- +Subscriptions
- −GraphQL complexity
- −Over-fetching solved but schema overhead
Hono
Best for: Edge HTTP APIs
Ultrafast, lightweight web framework for the edge — works on Cloudflare Workers, Deno, Bun, and Node with a tiny footprint.
- +Tiny & fast
- +Multi-runtime
- +Great middleware
- −REST/manual routes
- −not RPC-native
OpenAPI
Best for: Language-agnostic REST
Standard REST API specification (Swagger) — describe endpoints, generate clients/docs, and interoperate across languages.
- +Universal standard
- +Client generation
- +Tooling everywhere
- −Spec maintenance
- −No end-to-end TS inference
Compare
Tick the ones you want to compare
| Alternative | Paradigm | Type safety | Best for |
|---|---|---|---|
| ★tRPC | RPC | End-to-end | TS monorepo apps |
| Apollo GraphQL | GraphQL | Via codegen | Flexible client queries |
| Hono | HTTP / REST | Manual | Edge & serverless APIs |
| OpenAPI | REST spec | Via codegen | Public / multi-lang APIs |
tRPC is the pick for TypeScript monorepos where client and server share types. Apollo GraphQL when clients need flexible queries and a schema-first contract. Hono for fast HTTP APIs on the edge (Cloudflare Workers, etc.). OpenAPI for public REST APIs that must work across languages and teams. Pair with State & Data Fetching on the client and ORM & Query Builders on the server.