# @elysiajs/trpc

> A plugin for Elysia that add support for using tRPC

Latest version **1.1.0** (published 2024-07-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @elysiajs/trpc
pnpm add @elysiajs/trpc
yarn add @elysiajs/trpc
bun add @elysiajs/trpc
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2024-07-16 |
| First published | 2022-12-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 130.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 31 |
| Author | saltyAom |
| Maintainers | aomkirby123 |
| Keywords | elysia, trpc |

## Links

- npm: https://www.npmjs.com/package/@elysiajs/trpc
- Repository: https://github.com/elysiajs/elysia-trpc
- Issues: https://github.com/elysiajs/elysia-trpc/issues
- npm.io page: https://npm.io/package/@elysiajs/trpc

## Recent versions

- 1.1.0 (latest) — 2024-07-16
- 1.1.0-rc.0 (rc) — 2024-07-12
- 1.0.0-beta.1 (next) — 2024-02-16
- 1.0.2 — 2024-03-18
- 1.0.0 — 2024-03-16
- 1.0.0-rc.0 — 2024-03-01
- 1.0.0-beta.0 — 2024-02-06
- 0.8.0 — 2023-12-23
- 0.8.0-rc.0 — 2023-12-15
- 0.7.0 — 2023-09-20
- 0.7.0-beta.0 — 2023-09-18
- 0.6.1 — 2023-08-13
- 0.6.0 — 2023-08-06
- 0.6.0-rc.0 — 2023-08-06
- 0.5.2 — 2023-06-05
- … 16 more at https://npm.io/package/@elysiajs/trpc/versions

## README

# @elysiajs/trpc
A plugin for [elysia](https://github.com/elysiajs/elysia) that adds support for using tRPC.

## Installation
```bash
bun add @elysiajs/trpc
```

## Example
```typescript
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.

```typescript
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.

---
_Source: https://npm.io/package/@elysiajs/trpc · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
