orpc-building-custom-plugins
Create powerful custom plugins to extend oRPC handlers and links with interceptors.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Create powerful custom plugins to extend oRPC handlers and links with interceptors.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Quick reference for Better Notify configuration, patterns, and common gotchas
Interactive setup wizard for adding Better Notify to a TypeScript/JavaScript project
Context and API guidance for Better Notify — end-to-end typed notification infrastructure for Node.js
Seamlessly use AI SDK inside your oRPC projects without any extra overhead.
Use oRPC inside an Astro project.
Functions to encode and decode base64url strings (URL-safe variant of base64).
| name | oRPC Building Custom Plugins |
| description | Create powerful custom plugins to extend oRPC handlers and links with interceptors. |
| license | MIT |
| metadata | {"author":"Ali Torki","homepage":"https://github.com/ali-master","version":"1.0.0"} |
This guide explains how to create custom oRPC plugins for handlers and links.
In oRPC, a plugin is a collection of interceptors that can work together or independently.
export class ResponseHeadersPlugin<T extends ResponseHeadersPluginContext> implements StandardHandlerPlugin<T> {
init(options: StandardHandlerOptions<T>): void {
options.rootInterceptors ??= []
options.rootInterceptors.push(async (interceptorOptions) => {
const resHeaders = interceptorOptions.context.resHeaders ?? new Headers()
const result = await interceptorOptions.next({
...interceptorOptions,
context: { ...interceptorOptions.context, resHeaders },
})
if (!result.matched) return result
const responseHeaders = clone(result.response.headers)
for (const [key, value] of resHeaders) {
// merge headers
responseHeaders[key] = value
}
return { ...result, response: { ...result.response, headers: responseHeaders } }
})
}
}
Extend server-side handlers (RPCHandler, OpenAPIHandler). Work with interceptors from the Handler Lifecycle.
Enhance client-side communication (RPCLink, OpenAPILink). Use interceptors from the Link Lifecycle.
Use a unique symbol to inject context shared between interceptors. The Strict Get Method Plugin demonstrates this — it uses rootInterceptors to collect HTTP methods and combines them with procedure info in clientInterceptors.
export class ExamplePlugin<T extends Context> implements StandardHandlerPlugin<T> {
order = 10
init(options: StandardHandlerOptions<T>): void {
options.rootInterceptors ??= []
options.clientInterceptors ??= []
options.rootInterceptors.push(async ({ next }) => next())
options.clientInterceptors.push(async ({ next }) => next())
}
}
order controls plugin loading order, not interceptor execution order. Higher order with .unshift to run earlier, or .push to run later.
Avoid setting
orderunless necessary. Keep it below1_000_000to avoid conflicts with built-in plugins.