https://github.com/falcondev-oss/nitro-trpc-event-handler
tRPC event handler for Nitro
https://github.com/falcondev-oss/nitro-trpc-event-handler
nitro nitropack trpc trpc-server typescript
Last synced: about 1 month ago
JSON representation
tRPC event handler for Nitro
- Host: GitHub
- URL: https://github.com/falcondev-oss/nitro-trpc-event-handler
- Owner: falcondev-oss
- License: apache-2.0
- Created: 2025-01-14T06:40:18.000Z (5 months ago)
- Default Branch: master
- Last Pushed: 2025-04-24T05:42:23.000Z (about 2 months ago)
- Last Synced: 2025-04-24T05:45:15.669Z (about 2 months ago)
- Topics: nitro, nitropack, trpc, trpc-server, typescript
- Language: TypeScript
- Homepage:
- Size: 115 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tRPC Nitro Event Handler
[tRPC](https://trpc.io/docs/) event handler for [Nitro](https://nitro.build/) with support for Nitro's helper functions (e.g. `sendStream` or `sendRedirect`).
Also works with any Nitro based framework like [Nuxt](https://nuxt.com/) or [SolidStart](https://start.solidjs.com/).> [!WARNING]
> Only works with tRPC v11## Installation
```bash
npm install @falcondev-oss/nitro-trpc-event-handler
```## Usage
`api/trpc/[trpc].ts` (← make sure to name the path segment `trpc`)
```typescript
import { defineTRPCEventHandler } from '@falcondev-oss/nitro-trpc-event-handler'
import { appRouter } from './trpc/router'export default defineTRPCEventHandler({
router: appRouter,
createContext: (event) => {
// add your own tRPC context here
return {
event,
}
},
})
```