Astro Integration
Astro is a JavaScript web framework optimized for building fast, content-driven websites. For additional context, refer to the HTTP Adapter guide.
Basic
ts
import { RPCHandler } from '@orpc/server/fetch'
const handler = new RPCHandler(router)
export const prerender = false
export const ALL: APIRoute = async ({ request }) => {
const { response } = await handler.handle(request, {
prefix: '/rpc',
context: {},
})
return response ?? new Response('Not found', { status: 404 })
}
INFO
The handler
can be any supported oRPC handler, such as RPCHandler, OpenAPIHandler, or another custom handler.