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.

Datos de origen

Repositorio
FranciscoMoretti/chat-js
Última actividad en el origen
12 de septiembre de 2026 a las 06:41
Idioma detectado de SKILL.md
inglés
Estrellas
1200
Forks
124

Opciones de instalación

De forma predeterminada está seleccionado el prompt que primero revisa el origen. Puedes cambiar a un comando directo o descargar una copia local.

Revisa los archivos de origen

Lee SKILL.md y los archivos complementarios que muestra SkillsMP antes de decidir si quieres instalarlo.

Mostrando SKILL.md

SKILL.md
Instrucciones de origen · Vista previa de solo lectura
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.
Ver en GitHub