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.

소스 정보

저장소
FranciscoMoretti/chat-js
최근 소스 활동
2026년 9월 12일 06:41
감지된 SKILL.md 언어
영어
스타
1,200
포크
124

설치 방법

기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.

소스 파일 검토

설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.

SKILL.md 표시 중

SKILL.md
소스 지침 · 읽기 전용 미리보기
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.
GitHub에서 보기