← Back to list

frontend-patterns
by grmkris
⭐ 2🍴 0📅 Jan 24, 2026
SKILL.md
name: frontend-patterns description: React/Next.js data patterns - React Query hooks, ORPC client integration, error handling, cache invalidation. Complements frontend-design skill (visuals).
React/Next.js Patterns
Use this skill for data layer and React patterns. For visual design, use frontend-design skill.
Project Setup
Replace these placeholders for your project:
@project/→ your package scope (e.g.,@myapp/)apps/web/paths follow standard monorepo layout
Expected setup:
@project/auth- better-auth config@project/shared- SERVICE_URLS, shared types@/utils/orpc- ORPC client, queryClient
ORPC Client Setup
import { client, orpc, queryClient } from "@/utils/orpc";
const data = await client.item.get({});
const queryKey = orpc.item.get.queryOptions({}).queryKey;
Quick Patterns
Query Hook
"use client";
import { useQuery } from "@tanstack/react-query";
import { orpc } from "@/utils/orpc";
export function useItems() {
return useQuery(orpc.item.list.queryOptions({}));
}
Mutation Hook
"use client";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { toast } from "sonner";
import { client, orpc } from "@/utils/orpc";
export function useCreateItem() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: async (input) => client.item.create(input),
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: orpc.item.list.queryOptions({ input: {} }).queryKey,
});
toast.success("Created!");
},
onError: (error) => {
toast.error(error instanceof Error ? error.message : "Failed");
},
});
}
Additional Resources
- For detailed hook patterns and error handling, see hooks.md
- For auth client and provider setup, see providers.md
File Locations
| Pattern | Location |
|---|---|
| Hooks | apps/web/src/hooks/ |
| ORPC client | apps/web/src/utils/orpc.ts |
| Types | apps/web/src/lib/orpc-types.ts |
| Auth client | apps/web/src/lib/auth-client.ts |
| Providers | apps/web/src/components/providers.tsx |
Best Practices
- Always "use client" at top of hook files
- Import from @/utils/orpc for client/orpc/queryClient
- Toast on success/error using Sonner
- Invalidate related queries in onSuccess
- Handle error codes explicitly with switch statement
Score
Total Score
50/100
Based on repository quality metrics
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
Reviews
💬
Reviews coming soon