Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
dimitrigilbert avatar

Trpc

  • 7 installs
  • 5 repo stars
  • Updated June 3, 2026
  • dimitrigilbert/ai-skills

Set up type-safe tRPC routers and clients across any framework using Zod-validated procedures.

About

Generic tRPC implementation guide for building type-safe APIs across any framework and package manager. A developer uses it to set up tRPC routers and clients in a TypeScript app.

  • Framework-agnostic tRPC router with Zod-validated query and mutation procedures
  • Type-safe frontend client via httpBatchLink and TanStack React Query

Trpc by the numbers

  • 7 all-time installs (skills.sh)
  • Ranked #3,637 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
  • Data as of Jul 29, 2026 (Skillselion catalog sync)
npx skills add https://github.com/dimitrigilbert/ai-skills --skill trpc

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs7
repo stars5
Last updatedJune 3, 2026
Repositorydimitrigilbert/ai-skills

What it does

Set up type-safe tRPC routers and clients across any framework using Zod-validated procedures.

Files

SKILL.mdMarkdownGitHub ↗

tRPC Quick Start

Backend Router

import { initTRPC, TRPCError } from "@trpc/server";
import { z } from "zod";

export const t = initTRPC.create();
export const router = t.router;
export const publicProcedure = t.procedure;

export const myRouter = router({
  getItem: publicProcedure
    .input(z.object({ id: z.string() }))
    .query(async ({ input }) => {
      return await getItem(input.id);
    }),

  updateItem: publicProcedure
    .input(z.object({ id: z.string(), data: z.any() }))
    .mutation(async ({ input }) => {
      return await updateItem(input.id, input.data);
    }),
});

export const appRouter = router({
  healthCheck: publicProcedure.query(() => "OK"),
  my: myRouter,
});

export type AppRouter = typeof appRouter;

Frontend Client

import { createTRPCClient, httpBatchLink } from "@trpc/client";
import { createTRPCOptionsProxy } from "@trpc/tanstack-react-query";
import type { AppRouter } from "./path/to/router";
import { QueryClient } from "@tanstack/react-query";

export const queryClient = new QueryClient();
export const trpcClient = createTRPCClient<AppRouter>({
  links: [httpBatchLink({ url: "/api/trpc" })],
});

export const trpc = createTRPCOptionsProxy<AppRouter>({
  client: trpcClient,
  queryClient,
});

Usage

const { data } = useQuery(trpc.my.getItem.queryOptions({ id }));
const mutation = useMutation(trpc.my.updateItem.mutationOptions());

Error Handling

throw new TRPCError({
  code: "NOT_FOUND",
  message: "Resource not found",
});

Advanced

  • Subscriptions: See SUBSCRIPTIONS.md
  • Server Adapters: See ADAPTERS.md
  • Context: See CONTEXT.md
  • Router Merging: See ROUTERS.md
  • Middleware: See MIDDLEWARE.md
  • Frontend Patterns: See FRONTEND.md
  • Client Links: See LINKS.md
  • Schemas: See SCHEMAS.md
  • Client Errors: See CLIENT_ERRORS.md
  • Install: See INSTALL.md

Related skills

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.