Skip to main content
Orionjs provides seamless integration with tRPC for building end-to-end type-safe APIs. The @orion-js/trpc package offers decorators and utilities that work with Orionjs schemas and the service injection system.

Installation

Key Features

  • Full TypeScript type inference
  • Integration with Orionjs schema validation
  • Service injection support via @Inject()
  • Compatible with the Orionjs component system

Basic Setup

1. Create Procedures

Create a procedures class using the @Procedures() decorator:

2. Register in a Component

Add your procedure classes to a component’s trpc controllers:

3. Set Up the tRPC Server

Create a local t config and mount routes with registerTRPCRoute:
Because you call initTRPC.create() directly, the router type reflects your configuration.

4. Wire Everything Together

The component() and mergeComponents() functions are generic, so tRPC procedure types flow through automatically:

Type Inference Requirement

Enable strictNullChecks in both backend and frontend tsconfig for native transformer type inference:

File Organization

Recommended structure for tRPC procedures:
The controllers/trpc/index.ts: