Skip to content
You are reading the v2 docs, currently in beta.V1 docs
oRPC
Esc
navigateopen⌘Jpreview
On this page

H3 Adapter

Use oRPC inside an H3 project by mounting a handler on a wildcard route.

H3 is a universal, tiny, and fast web framework built on top of web standards, so oRPC integrates through the Fetch API Adapter.

Basic

import { onError } from '@orpc/server'
import { RPCHandler } from '@orpc/server/fetch'
import { H3, serve } from 'h3'

const app = new H3()

const handler = new RPCHandler(router, {
  interceptors: [
    onError((error) => {
      console.error(error)
    }),
  ],
})

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

Last updated on August 25, 2026

Was this page helpful?