Skip to main content

trpc-patterns

Implement ChatJS tRPC routers, TanStack Query hooks, mutations, and cache invalidation. Use when adding or changing tRPC procedures or their React consumers in apps/chat.

Quellinformationen

Repository
FranciscoMoretti/chat-js
Letzte Quellaktivität
12. September 2026 um 06:41
Erkannte Sprache von SKILL.md
Englisch
Sterne
1.200
Forks
124

Installationsoptionen

Standardmäßig ist der Prompt ausgewählt, der zuerst die Quelle prüft. Sie können zu einem direkten Befehl wechseln oder eine lokale Kopie herunterladen.

Quelldateien prüfen

Lesen Sie SKILL.md und alle von SkillsMP angezeigten Begleitdateien, bevor Sie sich für eine Installation entscheiden.

SKILL.md wird angezeigt

SKILL.md
Quellanweisungen · Schreibgeschützte Vorschau
name
trpc-patterns
description
Implement ChatJS tRPC routers, TanStack Query hooks, mutations, and cache invalidation. Use when adding or changing tRPC procedures or their React consumers in apps/chat.
# ChatJS tRPC patterns ## Backend - Add feature routers under `apps/chat/trpc/routers/*.router.ts` and register them in `apps/chat/trpc/routers/_app.ts`. - Use `protectedProcedure` for authenticated operations. - Validate inputs with Zod and verify ownership before mutations. - Keep database access in `apps/chat/lib/db/queries.ts`. ## React queries Use `useTRPC()` with TanStack Query: ```tsx const trpc = useTRPC(); const query = useQuery({ ...trpc.feature.list.queryOptions(), enabled: Boolean(condition), }); ``` For mutations, use generated mutation options and invalidate related keys after success: ```tsx const trpc = useTRPC(); const queryClient = useQueryClient(); const mutation = useMutation( trpc.feature.update.mutationOptions({ onSuccess: () => queryClient.invalidateQueries({ queryKey: trpc.feature.list.queryKey(), }), }) ); ``` Handle loading and error states in the consumer.
Auf GitHub ansehen