Skip to content

tRPC Plugin ​

This plugin adds support for using tRPC

Install with:

bun add @elysiajs/trpc @trpc/server @elysiajs/websocket

Then use it:

import { compile as c, trpc } from "@elysiajs/trpc";
import { initTRPC } from "@trpc/server";
import { Elysia, t as T } from "elysia";

const t = initTRPC.create();
const p = t.procedure;

const router = t.router({
  greet: p

    // ðŸ’Ą Using Zod
    // ðŸ’Ą Using Elysia's T
    .query(({ input }) => input),

export type Router = typeof router;

const app = new Elysia().use(trpc(router)).listen(3000);

trpc ​

Accept the tRPC router and register to Elysia's handler.


trpc(router: Router, option?: {
    endpoint?: string
}): this

Router is the TRPC Router instance.

endpoint ​

The path to the exposed TRPC endpoint.