Skip to content

falcondev-oss/nitro-trpc-event-handler

Repository files navigation

tRPC Nitro Event Handler

tRPC event handler for Nitro with support for Nitro's helper functions (e.g. sendStream or sendRedirect). Also works with any Nitro based framework like Nuxt or SolidStart.

Warning

Only works with tRPC v11

Installation

npm install @falcondev-oss/nitro-trpc-event-handler

Usage

api/trpc/[trpc].ts (← make sure to name the path segment trpc)

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,
    }
  }
})