auth

Implement JWT and cookie authentication for tRPC across HTTP, WebSocket, and SSE transports.

2|Updated Apr 11, 2026
One-click install
npx skills add https://github.com/PlazaCC/antes-da-tela --skill auth-plazacc
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: auth
Source: https://github.com/PlazaCC/antes-da-tela/tree/main/.agents/skills/auth
Command: npx skills add https://github.com/PlazaCC/antes-da-tela --skill auth-plazacc

SYSTEM DOCUMENTATION & REQUIREMENTS

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.

Frequently Asked Questions about auth

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I secure tRPC endpoints with JWT and cookies?

Secure tRPC endpoints with JWT and cookies by extracting user credentials in createContext, enforcing access via middleware, and propagating auth state across HTTP, WebSocket, and SSE client transports.

How do I implement protected procedures in tRPC?

Implement protected procedures in tRPC by applying middleware-based authorization that narrows the context to a non-null user, then using that pattern as a base for all protected routes.

How do I pass JWT tokens over WebSocket connections in tRPC?

Pass JWT tokens over WebSocket connections in tRPC by configuring the client transport to include auth credentials via connectionParams, ensuring persistent sessions across the transport layer.

Can I use cookies for tRPC authentication across SSE and HTTP transports?

Yes, you can use cookies for tRPC authentication across SSE and HTTP transports by wiring client links to send auth headers, with SSE supporting cookies or EventSource polyfill headers for sessions.

Does tRPC middleware support context narrowing for user authorization?

Yes, tRPC middleware supports context narrowing for user authorization by verifying credentials in createContext and then narrowing the context type to enforce a non-null user for protected procedures.

What is the best way to structure tRPC auth for HTTP and WebSocket clients?

The best way to structure tRPC auth is to centralize user extraction in createContext, enforce access with a protectedProcedure middleware, and propagate headers across HTTP and WebSocket transports.