dimitrigilbert/ai-skills

trpc

Generic tRPC implementation guide. Works with any framework (Next.js, Express, Fastify, Hono, Bun) and any package manager (pnpm, npm, yarn, bun).

First seen Feb 5, 2026

Installation

$ npx skills add dimitrigilbert/ai-skills --skill trpc

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from dimitrigilbert/ai-skills · top by installs.

npx skills add dimitrigilbert/ai-skills

Browse all from dimitrigilbert/ai-skills

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Stars 5
License LICENSE
Default branch main
Open issues 1
Status Active

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 2,394 B
  • docs SUMMARY.md 158 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 8 installs

SKILL.md

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](references/SUBSCRIPTIONS.md)
  • Server Adapters: See [ADAPTERS.md](references/ADAPTERS.md)
  • Context: See [CONTEXT.md](references/CONTEXT.md)
  • Router Merging: See [ROUTERS.md](references/ROUTERS.md)
  • Middleware: See [MIDDLEWARE.md](references/MIDDLEWARE.md)
  • Frontend Patterns: See [FRONTEND.md](references/FRONTEND.md)
  • Client Links: See [LINKS.md](references/LINKS.md)
  • Schemas: See [SCHEMAS.md](references/SCHEMAS.md)
  • Client Errors: See [CLIENTERRORS.md](references/CLIENTERRORS.md)
  • Install: See [INSTALL.md](references/INSTALL.md)