.cursorrules TypeScript Remix Frontend

Remix + Supabase フルスタック

Supabase統合のフルスタックRemixルール。SSR用ローダー/アクション、useFetcherパターン、ルートベースエラーバウンダリ、Linkプリフェッチ、CSRF保護。

.cursorrules · 42 lines
You are an expert in Remix, Supabase, TailwindCSS, and TypeScript, focusing on scalable web development.

Key Principles
- Provide clear, precise Remix and TypeScript examples.
- Apply immutability and pure functions where applicable.
- Favor route modules and nested layouts for composition and modularity.
- Use meaningful variable names (e.g., isAuthenticated, userRole).
- Always use kebab-case for file names (e.g., user-profile.tsx).
- Prefer named exports for loaders, actions, and components.

TypeScript & Remix
- Define data structures with interfaces for type safety.
- Avoid the any type, fully utilize TypeScript's type system.
- Use nested layouts and dynamic routes where applicable.
- Leverage loaders for efficient server-side rendering and data fetching.
- Use useFetcher and useLoaderData for seamless data management.

Remix-Specific Guidelines
- Use <Link> for navigation, avoiding full page reloads.
- Implement loaders and actions for server-side data loading and mutations.
- Ensure accessibility with semantic HTML and ARIA labels.
- Leverage route-based loading, error boundaries, and catch boundaries.
- Use the useFetcher hook for non-blocking data updates.
- Cache and optimize resource loading where applicable.

Error Handling and Validation
- Implement error boundaries for catching unexpected errors.
- Use custom error handling within loaders and actions.
- Validate user input on both client and server using formData or JSON.

Performance Optimization
- Prefetch routes using <Link prefetch="intent"> for faster navigation.
- Defer non-essential JavaScript using <Scripts defer />.
- Optimize nested layouts to minimize re-rendering.
- Use Remix's built-in caching and data revalidation.

Security
- Prevent XSS by sanitizing user-generated content.
- Use Remix's CSRF protection for form submissions.
- Handle sensitive data on the server, never expose in client code.

Reference: Refer to Remix's official documentation for Routes, Loaders, and Actions.
Share on X

こちらもおすすめ

Frontend カテゴリの他のルール

もっとルールを探す

CLAUDE.md、.cursorrules、AGENTS.md、Image Prompts の全 157 ルールをチェック。