tRPC Plugin â
This plugin adds support for using tRPC
Install with:
bash
bun add @elysiajs/trpc @trpc/server @elysiajs/websocket
bun add @elysiajs/trpc @trpc/server @elysiajs/websocket
Then use it:
typescript
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
//.input(z.string())
// ðĄ Using Elysia's T
.input(c(T.String()))
.query(({ input }) => input),
});
export type Router = typeof router;
const app = new Elysia().use(trpc(router)).listen(8080);
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
//.input(z.string())
// ðĄ Using Elysia's T
.input(c(T.String()))
.query(({ input }) => input),
});
export type Router = typeof router;
const app = new Elysia().use(trpc(router)).listen(8080);
trpc â
Accept the tRPC router and register to Elysia's handler.
type:
trpc(router: Router, option?: {
endpoint?: string
}): this
trpc(router: Router, option?: {
endpoint?: string
}): this
Router
is the TRPC Router instance.
endpoint â
The path to the exposed TRPC endpoint.