What problem does it solve?
Implement authentication and authorization for tRPC by providing a clear pattern for extracting the user from requests, enforcing access controls, and propagating auth state across HTTP, WebSocket, and SSE transports.
Core Features & Use Cases
- Context creation with createContext to extract and verify user credentials from request headers.
- Middleware-based authorization that narrows ctx to a non-null user and protects procedures via protectedProcedure.
- Client integration across transports: HTTP headers, WebSocket connectionParams, and SSE cookies or EventSource polyfill headers for persistent sessions.
Quick Start
Configure your tRPC setup to extract the user from incoming requests, apply protectedProcedure for protected routes, and wire client links to send Authorization headers across HTTP, WebSocket, and SSE transports.