trpc-web-worker

Implements typed tRPC communication between a Vercel web app and a Fly.io worker service.

Updated Mar 31, 2026
One-click install
npx skills add https://github.com/gengirish/dropflow --skill trpc-web-worker-gengirish
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: trpc-web-worker
Source: https://github.com/gengirish/dropflow/tree/main/.cursor/skills/trpc-web-worker
Command: npx skills add https://github.com/gengirish/dropflow --skill trpc-web-worker-gengirish

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @trpc/server, @trpc/client, zod.

What problem does it solve? Setting up end-to-end type-safe communication between a Next.js web app on Vercel and a background worker on Fly.io is error-prone, especially around router definitions, context propagation, and cross-service authentication. This Skill provides working patterns for building that tRPC bridge. ## Core Features & Use Cases - Worker-Side Router: Defines tRPC routers with Zod-validated procedures for queue enqueueing, workflow run lookups, and health checks. - Express Middleware Mounting: Mounts the tRPC router on the worker's Express server with tenant-scoped context extracted from headers. - Typed Web Client: Creates a fully typed tRPC client in the web app using httpBatchLink, importing the AppRouter type for end-to-end type safety. - Use Case: When a user places an order in the web app, a server action calls workerClient.enqueue.mutate to push a typed job onto the order-queue on the Fly.io worker, authenticated via a shared secret. ## Quick Start Ask the AI to add a new tRPC procedure to the worker router and call it from a web server action using the typed worker client.

Frequently Asked Questions about trpc-web-worker

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

FAQPage Schema
How do I set up tRPC between two separate services?▼

Define the router with initTRPC on the server side, mount it via createExpressMiddleware, then create a typed client with createTRPCClient and httpBatchLink pointing at the remote URL. Import the AppRouter type in the client for end-to-end type safety.

How to add a new tRPC procedure with input validation?▼

Add a procedure to the router using t.procedure with a Zod schema in .input() for validation, then implement .query() or .mutation() with the handler logic. The input types are automatically inferred and enforced at runtime.

How do I authenticate requests between web and worker services?▼

Use a shared secret sent as a custom header like x-worker-secret from the client, configured via the headers option in httpBatchLink. The worker verifies this header against its environment variable before processing requests.

Can tRPC pass tenant context through request headers?▼

Yes, the createContext function in createExpressMiddleware receives the Express request and can extract headers like x-tenant-id. This value becomes available as ctx.tenantId inside every procedure for tenant-scoped operations.

When should I use tRPC instead of REST between services?▼

tRPC fits when both services are TypeScript and you want compile-time type safety without code generation. For public APIs, non-TypeScript consumers, or language-agnostic integrations, REST or GraphQL is a better fit.