@elysiajs/trpc
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

@elysiajs/trpc

A plugin for elysia that adds support for using tRPC.

Installation

bun add @elysiajs/trpc

Example

import { Elysia, t } from 'elysia'
import { trpc, compile as c } from '@elysiajs/trpc'

import { initTRPC } from '@trpc/server'

const r = initTRPC.create()

const router = r.router({
    greet: r.procedure.input(c(t.String())).query(({ input }) => input)
})

export type Router = typeof router

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

API

This plugin extends the new method trpc to Elysia class.

trpc

Register tRPC router.

type tRPC = (router: Router<any>, options?: TRPCOptions) => this

export interface TRPCOptions
    extends Omit<
        FetchHandlerRequestOptions<any>,
        'req' | 'router' | 'endpoint'
    > {
    /**
     * tRPC endpoint
     *
     * @default '/trpc'
     */
    endpoint?: string
}

Note

WebSocket API is in an experimental state and unstable.

Is meant for experimental for better stabilization.

Readme

Keywords

Package Sidebar

Install

npm i @elysiajs/trpc

Weekly Downloads

2,590

Version

1.0.2

License

MIT

Unpacked Size

39.2 kB

Total Files

18

Last publish

Collaborators

  • aomkirby123