Nuxt.js Integration
Nuxt.js is a popular Vue.js framework for building server-side applications. It built on top of Nitro server a lightweight, high-performance Node.js runtime. For more details, see the Node Integration guide.
Basic
ts
import { RPCHandler } from '@orpc/server/node'
const handler = new RPCHandler(router)
export default defineEventHandler(async (event) => {
const { matched } = await handler.handle(
event.node.req,
event.node.res,
{
prefix: '/rpc',
context: {}, // Provide initial context if needed
}
)
if (matched) {
return
}
setResponseStatus(event, 404, 'Not Found')
return 'Not found'
})
ts
export { default } from './[...]'
INFO
The handler
can be any supported oRPC handler, such as RPCHandler, OpenAPIHandler, or another custom handler.