oRPC Browser Adapter
Installation
SKILL.md
Browser Adapter
Enable type-safe communication between browser scripts using the Message Port Adapter.
Between Extension Scripts
Browser extension Message Passing API doesn't support transferring binary data. Workaround: extend the RPC JSON Serializer to encode binary data as Base64.
Server (background/content script):
import { RPCHandler } from '@orpc/server/message-port'
import { onError } from '@orpc/server'
const handler = new RPCHandler(router, {
interceptors: [onError(e => console.error(e))],
})