oRPC
background

Integrations

Integrating oRPC with your existing stacks, environments, and frameworks.

Introduction

oRPC is design with Fetch API in mind, so you can use it in any modern environment and framework.

import {  } from '@orpc/server/fetch'
import {  } from 'srvx'
import {  } from 'examples/server'
 
const  = ({
  ,
  : false, // set true will improve cold start times
})
 
 
const  = ({
  () {
    return ({
      ,
      : {},
      : '/api',
    })
  },
  : 2206,
})
 
await .()
 
// biome-ignore lint/suspicious/noConsole: <explanation>
.(`🚀 Server ready at ${.}`)

Under the hood, oRPC utilizes the RegExpRouter from Hono (the fastest router in the JavaScript ecosystem). We also provide first-class support for Edge and serverless environments.

Hono

While oRPC uses Hono's routing engine internally, there are additional benefits to using oRPC with Hono directly.

import {  } from 'hono'
import {  } from '@orpc/server/fetch'
import {  } from 'examples/server'
 
// For performance, create a global router handler
const  = ({
  ,
  : false, // Set to true to improve cold start times
})
 
const  = new ()
 
.('/api/*', () => {
  return ({
    : ..,
    : '/api',
    : {},
  }) 
})
 
export default 

Next.JS

As of Next.js 13, you can use the Fetch API for route handlers.

app/api/[[...orpc]].ts
import {  } from '@orpc/server/fetch'
import {  } from 'examples/server'
 
// For performance, create a global router handler
const  = ({
  ,
  : false, // Set to true to improve cold start times
})
 
const  = async (: Request) => {
  return ({
    ,
    : '/api',
    : {},
  }) 
}
 
export const  = 
export const  = 
export const  = 
export const  = 
export const  = 

Cloudflare Worker

Cloudflare Workers support Fetch API out of the box.

import {  } from '@orpc/server/fetch'
import {  } from 'examples/server'
 
// For performance, create a global router handler
const  = ({
  ,
  : true, // Set to true to improve cold start times
})
 
export default {
  async (: Request) {
    return ({
      ,
      : '/',
      : {},
    })
  },
}

Other Environments and Frameworks

Since most modern environments and frameworks support the Fetch API, you can use oRPC with virtually any environment or framework.

On this page