H3 Adapter
H3 is a universal, tiny, and fast web framework built on top of web standards. For additional context, refer to the HTTP Adapter guide.
Basic
ts
import { H3, serve } from 'h3'
import { RPCHandler } from '@orpc/server/fetch'
const app = new H3()
const handler = new RPCHandler(router)
app.use('/rpc/**', async (event) => {
const { matched, response } = await handler.handle(event.req, {
prefix: '/rpc',
context: {} // Provide initial context if needed
})
if (matched) {
return response
}
})
serve(app, { port: 3000 })
INFO
The handler
can be any supported oRPC handler, such as RPCHandler, OpenAPIHandler, or another custom handler.