BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News oRPC Releases Version 1.0 with OpenAPI Support and End to End Type Safety

oRPC Releases Version 1.0 with OpenAPI Support and End to End Type Safety

Listen to this article -  0:00

oRPC, a TypeScript library for building Typesafe APIs, has officially released version 1.0, marking a stable production-ready milestone for developers seeking an alternative to existing RPC and REST solutions with full OpenAPI integration.

oRPC 1.0 introduces a set of features designed to simplify API development while maintaining enterprise-grade type safety. The release includes first-class OpenAPI support, end-to-end type safety for inputs, outputs, and errors, native support for complex types like Date and File, and seamless integration with popular frontend frameworks including React, Vue, Solid, and Svelte through TanStack Query.

At the core of oRPC's design philosophy is what the team calls "powerful simplicity." Developers can define API endpoints with a syntax that feels similar to writing standard functions, while automatically gaining production features like OpenAPI specification generation, server action compatibility, and contract-first workflow support. The library supports multiple schema validators out of the box, including Zod, Valibot, and ArkType, without requiring additional configuration.

One of the standout features in oRPC 1.0 is its comprehensive OpenAPI implementation. Unlike competing solutions that require third-party plugins or have deprecated OpenAPI support, oRPC builds OpenAPI adherence directly into its core architecture. The library also supports multiple schema validators simultaneously and includes bracket notation support for more complex API structures, features that are absent from alternatives like tRPC and ts-rest.

The syntax for defining procedures in oRPC follows a chainable pattern that integrates middleware, validation, and error handling. An example of a typical oRPC procedure is shown below:

 

const getBands = os
 .use(dbProvider)
 .use(requiredAuth)
 .route({ method: 'GET', path: '/bands/{id}' })
 .input(z.object({ id: z.string() }))
 .handler(async ({ input, context }) => {
 // Implementation logic
 })

Performance benchmarks published alongside the release show notable improvements over tRPC, with oRPC demonstrating 1.6 times faster type checking, 2.8 times faster runtime performance, and a bundle size that is roughly half that of tRPC's equivalent setup. The library also shows reduced memory consumption at 103MB compared to tRPC's 268MB in testing scenarios, though the team notes these results can vary based on project complexity and environment.

For developers looking to migrate from existing solutions, oRPC provides detailed migration guides with side-by-side code comparisons. The migration documentation covers the transition from tRPC, including installation steps, conceptual mappings, and updated patterns for routers, procedures, and client setup. The core migration involves replacing t.procedure with os, consolidating query and mutation methods into a unified .handler, and switching from TRPCError to ORPCError for error handling.

Community response to the release has been measured, with developers expressing interest in the OpenAPI integration and multi-framework support. A discussion on GitHub asks questions around integration patterns with authentication libraries and optimal plugin configurations, suggesting early adopters are actively testing production scenarios.

On Reddit, developers have been debating the necessity of RPC libraries in modern Next.js projects, with the consensus emerging that while Next.js server actions provide adequate type safety for simple CRUD operations, oRPC remains valuable for specific use cases. One developer noted using oRPC specifically for server-sent events, while another highlighted that the key differentiator is oRPC's built-in OpenAPI support, which server actions cannot provide.

When compared to competitors, oRPC positions itself uniquely in the TypeScript API tooling landscape. While tRPC excels at React-focused type safety without OpenAPI, and ts-rest provides contract-first development with OpenAPI support, oRPC attempts to bridge both approaches. The comparison documentation shows oRPC offering features like Cloudflare WebSocket hibernation, Vue Pinia Colada integration, and typesafe file handling that competitors either lack or require third-party solutions to achieve.

oRPC is an open-source TypeScript library developed by independent developer unnoq and licensed under MIT. The project supports multiple runtimes including Cloudflare Workers, Deno, Bun, and Node.js, making it suitable for edge computing scenarios and traditional server deployments alike.

About the Author

Rate this Article

Adoption
Style

BT