new-trpc-router

Create tRPC v11 routers with Zod validation and register them in appRouter.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Creating new API domains in a tRPC-based Next.js app often requires repetitive boilerplate: creating router files, defining procedures with input validation, co-locating database queries, and registering the router in the central appRouter. This Skill standardizes that workflow so new feature APIs are created consistently, validated, and discoverable by the application.

Core Features & Use Cases

  • Router file template: Provides a consistent pattern for list, byId, and create procedures and encourages input validation with Zod.
  • App registration guidance: Shows how to export the router and register it in server/api/root.ts so the appRouter exposes the new domain.
  • Auth and DB conventions: Recommends using publicProcedure for unauthenticated routes, adding Supabase auth checks for protected endpoints, and keeping queries co-located or extracting them to server/db/queries when large.
  • Use Case: Add a comments feature with endpoints to list comments, fetch a comment by UUID, and create new comments with server-side validation and auth.

Quick Start

Create a new router file named comments at server/api/routers/comments.ts with zod-validated procedures, export commentsRouter, and import and register it in server/api/root.ts so the appRouter exposes the comments domain.

Frequently Asked Questions about new-trpc-router

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

FAQPage Schema
How do I create a new tRPC router in Next.js?

To create a new tRPC router in Next.js, generate a router file under server/api/routers/<feature>.ts, implement procedures with Zod input schemas, export the router, and register it in server/api/root.ts to expose it via appRouter.

How do I add Zod input validation to tRPC procedures?

Add Zod input validation to tRPC procedures by defining a Zod schema and passing it to the procedure's input method before implementing the query or mutation logic within the router file.

How do I protect tRPC routes with Supabase auth?

Protect tRPC routes with Supabase auth by adding Supabase auth checks to protected procedures, while using publicProcedure for unauthenticated routes that do not require user verification.

Does this tRPC router setup work with Drizzle ORM?

Yes, this tRPC router setup works with Drizzle ORM, allowing you to co-locate database queries directly within procedures or extract larger queries to server/db/queries for better organization.

What is the best way to register a new tRPC router in the appRouter?

The best way to register a new tRPC router in the appRouter is to import the exported router from its feature file into server/api/root.ts and add it to the appRouter object to expose the new domain.