A complete tRPC v11 transport for ordered, reliable WebRTC data channels.
It provides a terminating client link and a server handler with:
- queries, mutations, subscriptions, and cancellation;
- tRPC transformers, custom error shapes, and typed context;
tracked()event IDs withretryLinkand reconnect resumption;- reusable channel factories, connection state, lifecycle callbacks, and server-requested reconnects;
- client and server keep-alive;
- bounded fair backpressure, frame limits, and concurrent-operation limits;
- browser WebRTC and Node.js WebRTC through
@webrtc-node/webrtc.
Applications remain responsible for authenticated SDP/ICE signaling and for creating a fresh data channel when a reconnecting factory is called.
npm install @webrtc-node/trpc-webrtc-link @trpc/client @trpc/serverNode.js WebRTC peers also install:
npm install @webrtc-node/webrtcPass the same established channel to createWebRTCLink() on the client and
createWebRTCHandler() beside the tRPC router:
const link = createWebRTCLink<AppRouter>({ channel });
const client = createTRPCClient<AppRouter>({ links: [link] });
createWebRTCHandler({
router: appRouter,
channel: peerChannel,
peer: authenticatedPeer,
createContext: ({ peer }) => ({ userId: peer.userId }),
});
await link.connect();
const greeting = await client.greeting.query();See the complete package guide, the connection lifecycle guide, the wire protocol reference, and the runnable browser-to-Node example.
Project history is in the changelog. Contributions and
security reports use the files under .github.