oRPC
background

Integrations

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

Integrate oRPC with various stacks, environments, and frameworks effortlessly. oRPC is designed with the Fetch API in mind, making it compatible with any modern environment or framework.

It uses the highly performant Hono RegExpRouter under the hood, ensuring low-latency routing. Whether you're targeting serverless, edge environments, or traditional backends, oRPC is optimized for all scenarios.

Quick Example

import { ,  } from '@orpc/server/fetch'
import { ,  } from '@orpc/openapi/fetch'
import {  } from 'examples/server'
 
export function (: Request) {
  return ({
    ,
    ,
    : {},
    // prefix: '/api', // Optionally define a route prefix
    : [
      (),
      (),
    ],
  })
}

Node.js

Node.js doesn't provide native support for creating server with Fetch API, but you can easily use @whatwg-node/server as an adapter.

import { ,  } from '@orpc/server/fetch'
import { ,  } from '@orpc/openapi/fetch'
import {  } from 'node:http'
import {  } from '@whatwg-node/server'
import {  } from 'examples/server'
 
const  = (
  ((: Request) => {
    return ({
      ,
      ,
      : {},
      // prefix: '/api',
      : [
        (),
        (),
      ],
    })
  })
)
 
.(3000, () => {
  .('Server is available at http://localhost:3000')
})

Express.js

import { ,  } from '@orpc/server/fetch'
import { ,  } from '@orpc/openapi/fetch'
import {  } from '@whatwg-node/server'
import  from 'express'
import {  } from 'examples/server'
 
const  = ()
 
.('/api/*', ((: Request) => {
  return ({
    ,
    ,
    : {},
    : '/api',
      : [
        (),
        (),
      ],
  })
}))
 
.(3000, () => {
  .('Server is available at http://localhost:3000')
})

Hono

import {  } from 'hono'
import { ,  } from '@orpc/server/fetch'
import { ,  } from '@orpc/openapi/fetch'
import {  } from 'examples/server'
 
const  = new ()
 
.('/api/*', () => {
  return ({
    ,
    : ..,
    : '/api',
    : {},
    : [
      (),
      (),
    ],
  }) 
})
 
export default 

Next.js

app/api/[...orpc]/route.ts
import { ,  } from '@orpc/server/fetch'
import { ,  } from '@orpc/openapi/fetch'
import {  } from 'examples/server'
 
export function (: Request) {
  return ({
    ,
    ,
    : '/api',
    : {},
    : [
      (),
      (),
    ],
  })
}
 
export const  = 
export const  = 
export const  = 
export const  = 

Cloudflare Workers

import { ,  } from '@orpc/server/fetch'
import { ,  } from '@orpc/openapi/fetch'
import {  } from 'examples/server'
 
export default {
  async (: Request) {
    return ({
      ,
      ,
      : '/',
      : {},
      : [
        (),
        (),
      ],
    })
  },
}

Other Environments and Frameworks

oRPC works in any modern environment that supports the creating server with Fetch API. If not you can use @whatwg-node/server to create a server adapter.

On this page