Frontend Dev Guidelines

Build modern React apps with TypeScript, Suspense, and best practices

✨ The solution you've been looking for

Verified
Tested and verified by our team
8390 Stars

Frontend development guidelines for React/TypeScript applications. Modern patterns including Suspense, lazy loading, useSuspenseQuery, file organization with features directory, MUI v7 styling, TanStack Router, performance optimization, and TypeScript best practices. Use when creating components, pages, features, fetching data, styling, routing, or working with frontend code.

react typescript frontend suspense tanstack-query mui performance code-organization
Repository

See It In Action

Interactive preview & real-world examples

Live Demo
Skill Demo Animation

AI Conversation Simulator

See how users interact with this skill

User Prompt

Help me create a user profile component that fetches user data and follows modern React patterns

Skill Processing

Analyzing request...

Agent Response

Get a complete component using React.FC, useSuspenseQuery, proper file organization, and TypeScript best practices

Quick Start (3 Steps)

Get up and running in minutes

1

Install

claude-code skill install frontend-dev-guidelines

claude-code skill install frontend-dev-guidelines
2

Config

3

First Trigger

@frontend-dev-guidelines help

Commands

CommandDescriptionRequired Args
@frontend-dev-guidelines building-a-new-react-componentCreate a modern React component with proper TypeScript typing, lazy loading, and Suspense integrationNone
@frontend-dev-guidelines setting-up-a-new-featureStructure a complete feature with API layer, components, hooks, and routing using the features directory patternNone
@frontend-dev-guidelines optimizing-app-performanceApply lazy loading, code splitting, and performance optimization patterns to improve React app speedNone

Typical Use Cases

Building a New React Component

Create a modern React component with proper TypeScript typing, lazy loading, and Suspense integration

Setting Up a New Feature

Structure a complete feature with API layer, components, hooks, and routing using the features directory pattern

Optimizing App Performance

Apply lazy loading, code splitting, and performance optimization patterns to improve React app speed

Overview

Frontend Development Guidelines

Purpose

Comprehensive guide for modern React development, emphasizing Suspense-based data fetching, lazy loading, proper file organization, and performance optimization.

When to Use This Skill

  • Creating new components or pages
  • Building new features
  • Fetching data with TanStack Query
  • Setting up routing with TanStack Router
  • Styling components with MUI v7
  • Performance optimization
  • Organizing frontend code
  • TypeScript best practices

Quick Start

New Component Checklist

Creating a component? Follow this checklist:

  • Use React.FC<Props> pattern with TypeScript
  • Lazy load if heavy component: React.lazy(() => import())
  • Wrap in <SuspenseLoader> for loading states
  • Use useSuspenseQuery for data fetching
  • Import aliases: @/, ~types, ~components, ~features
  • Styles: Inline if <100 lines, separate file if >100 lines
  • Use useCallback for event handlers passed to children
  • Default export at bottom
  • No early returns with loading spinners
  • Use useMuiSnackbar for user notifications

New Feature Checklist

Creating a feature? Set up this structure:

  • Create features/{feature-name}/ directory
  • Create subdirectories: api/, components/, hooks/, helpers/, types/
  • Create API service file: api/{feature}Api.ts
  • Set up TypeScript types in types/
  • Create route in routes/{feature-name}/index.tsx
  • Lazy load feature components
  • Use Suspense boundaries
  • Export public API from feature index.ts

Import Aliases Quick Reference

AliasResolves ToExample
@/src/import { apiClient } from '@/lib/apiClient'
~typessrc/typesimport type { User } from '~types/user'
~componentssrc/componentsimport { SuspenseLoader } from '~components/SuspenseLoader'
~featuressrc/featuresimport { authApi } from '~features/auth'

Defined in: vite.config.ts lines 180-185


Common Imports Cheatsheet

 1// React & Lazy Loading
 2import React, { useState, useCallback, useMemo } from 'react';
 3const Heavy = React.lazy(() => import('./Heavy'));
 4
 5// MUI Components
 6import { Box, Paper, Typography, Button, Grid } from '@mui/material';
 7import type { SxProps, Theme } from '@mui/material';
 8
 9// TanStack Query (Suspense)
10import { useSuspenseQuery, useQueryClient } from '@tanstack/react-query';
11
12// TanStack Router
13import { createFileRoute } from '@tanstack/react-router';
14
15// Project Components
16import { SuspenseLoader } from '~components/SuspenseLoader';
17
18// Hooks
19import { useAuth } from '@/hooks/useAuth';
20import { useMuiSnackbar } from '@/hooks/useMuiSnackbar';
21
22// Types
23import type { Post } from '~types/post';

Topic Guides

🎨 Component Patterns

Modern React components use:

  • React.FC<Props> for type safety
  • React.lazy() for code splitting
  • SuspenseLoader for loading states
  • Named const + default export pattern

Key Concepts:

  • Lazy load heavy components (DataGrid, charts, editors)
  • Always wrap lazy components in Suspense
  • Use SuspenseLoader component (with fade animation)
  • Component structure: Props → Hooks → Handlers → Render → Export

📖 Complete Guide: resources/component-patterns.md


📊 Data Fetching

PRIMARY PATTERN: useSuspenseQuery

  • Use with Suspense boundaries
  • Cache-first strategy (check grid cache before API)
  • Replaces isLoading checks
  • Type-safe with generics

API Service Layer:

  • Create features/{feature}/api/{feature}Api.ts
  • Use apiClient axios instance
  • Centralized methods per feature
  • Route format: /form/route (NOT /api/form/route)

📖 Complete Guide: resources/data-fetching.md


📁 File Organization

features/ vs components/:

  • features/: Domain-specific (posts, comments, auth)
  • components/: Truly reusable (SuspenseLoader, CustomAppBar)

Feature Subdirectories:

features/
  my-feature/
    api/          # API service layer
    components/   # Feature components
    hooks/        # Custom hooks
    helpers/      # Utility functions
    types/        # TypeScript types

📖 Complete Guide: resources/file-organization.md


🎨 Styling

Inline vs Separate:

  • <100 lines: Inline const styles: Record<string, SxProps<Theme>>
  • 100 lines: Separate .styles.ts file

Primary Method:

  • Use sx prop for MUI components
  • Type-safe with SxProps<Theme>
  • Theme access: (theme) => theme.palette.primary.main

MUI v7 Grid:

1<Grid size={{ xs: 12, md: 6 }}>  // ✅ v7 syntax
2<Grid xs={12} md={6}>             // ❌ Old syntax

📖 Complete Guide: resources/styling-guide.md


🛣️ Routing

TanStack Router - Folder-Based:

  • Directory: routes/my-route/index.tsx
  • Lazy load components
  • Use createFileRoute
  • Breadcrumb data in loader

Example:

1import { createFileRoute } from '@tanstack/react-router';
2import { lazy } from 'react';
3
4const MyPage = lazy(() => import('@/features/my-feature/components/MyPage'));
5
6export const Route = createFileRoute('/my-route/')({
7    component: MyPage,
8    loader: () => ({ crumb: 'My Route' }),
9});

📖 Complete Guide: resources/routing-guide.md


⏳ Loading & Error States

CRITICAL RULE: No Early Returns

1// ❌ NEVER - Causes layout shift
2if (isLoading) {
3    return <LoadingSpinner />;
4}
5
6// ✅ ALWAYS - Consistent layout
7<SuspenseLoader>
8    <Content />
9</SuspenseLoader>

Why: Prevents Cumulative Layout Shift (CLS), better UX

Error Handling:

  • Use useMuiSnackbar for user feedback
  • NEVER react-toastify
  • TanStack Query onError callbacks

📖 Complete Guide: resources/loading-and-error-states.md


⚡ Performance

Optimization Patterns:

  • useMemo: Expensive computations (filter, sort, map)
  • useCallback: Event handlers passed to children
  • React.memo: Expensive components
  • Debounced search (300-500ms)
  • Memory leak prevention (cleanup in useEffect)

📖 Complete Guide: resources/performance.md


📘 TypeScript

Standards:

  • Strict mode, no any type
  • Explicit return types on functions
  • Type imports: import type { User } from '~types/user'
  • Component prop interfaces with JSDoc

📖 Complete Guide: resources/typescript-standards.md


🔧 Common Patterns

Covered Topics:

  • React Hook Form with Zod validation
  • DataGrid wrapper contracts
  • Dialog component standards
  • useAuth hook for current user
  • Mutation patterns with cache invalidation

📖 Complete Guide: resources/common-patterns.md


📚 Complete Examples

Full working examples:

  • Modern component with all patterns
  • Complete feature structure
  • API service layer
  • Route with lazy loading
  • Suspense + useSuspenseQuery
  • Form with validation

📖 Complete Guide: resources/complete-examples.md


Need to…Read this resource
Create a componentcomponent-patterns.md
Fetch datadata-fetching.md
Organize files/foldersfile-organization.md
Style componentsstyling-guide.md
Set up routingrouting-guide.md
Handle loading/errorsloading-and-error-states.md
Optimize performanceperformance.md
TypeScript typestypescript-standards.md
Forms/Auth/DataGridcommon-patterns.md
See full examplescomplete-examples.md

Core Principles

  1. Lazy Load Everything Heavy: Routes, DataGrid, charts, editors
  2. Suspense for Loading: Use SuspenseLoader, not early returns
  3. useSuspenseQuery: Primary data fetching pattern for new code
  4. Features are Organized: api/, components/, hooks/, helpers/ subdirs
  5. Styles Based on Size: <100 inline, >100 separate
  6. Import Aliases: Use @/, ~types, ~components, ~features
  7. No Early Returns: Prevents layout shift
  8. useMuiSnackbar: For all user notifications

Quick Reference: File Structure

src/
  features/
    my-feature/
      api/
        myFeatureApi.ts       # API service
      components/
        MyFeature.tsx         # Main component
        SubComponent.tsx      # Related components
      hooks/
        useMyFeature.ts       # Custom hooks
        useSuspenseMyFeature.ts  # Suspense hooks
      helpers/
        myFeatureHelpers.ts   # Utilities
      types/
        index.ts              # TypeScript types
      index.ts                # Public exports

  components/
    SuspenseLoader/
      SuspenseLoader.tsx      # Reusable loader
    CustomAppBar/
      CustomAppBar.tsx        # Reusable app bar

  routes/
    my-route/
      index.tsx               # Route component
      create/
        index.tsx             # Nested route

Modern Component Template (Quick Copy)

 1import React, { useState, useCallback } from 'react';
 2import { Box, Paper } from '@mui/material';
 3import { useSuspenseQuery } from '@tanstack/react-query';
 4import { featureApi } from '../api/featureApi';
 5import type { FeatureData } from '~types/feature';
 6
 7interface MyComponentProps {
 8    id: number;
 9    onAction?: () => void;
10}
11
12export const MyComponent: React.FC<MyComponentProps> = ({ id, onAction }) => {
13    const [state, setState] = useState<string>('');
14
15    const { data } = useSuspenseQuery({
16        queryKey: ['feature', id],
17        queryFn: () => featureApi.getFeature(id),
18    });
19
20    const handleAction = useCallback(() => {
21        setState('updated');
22        onAction?.();
23    }, [onAction]);
24
25    return (
26        <Box sx={{ p: 2 }}>
27            <Paper sx={{ p: 3 }}>
28                {/* Content */}
29            </Paper>
30        </Box>
31    );
32};
33
34export default MyComponent;

For complete examples, see resources/complete-examples.md


  • error-tracking: Error tracking with Sentry (applies to frontend too)
  • backend-dev-guidelines: Backend API patterns that frontend consumes

Skill Status: Modular structure with progressive loading for optimal context management

What Users Are Saying

Real feedback from the community

Environment Matrix

Dependencies

React 18+ (with Suspense support)
TypeScript 4.5+
TanStack Query v5
TanStack Router
MUI v7
Vite (for import aliases)

Framework Support

React 18 ✓ (recommended) TanStack Query v5 ✓ (recommended) TanStack Router ✓ (recommended) Material-UI v7 ✓ (recommended) Vite ✓ (recommended for build tooling)

Context Window

Token Usage ~3K-8K tokens depending on component complexity and feature scope

Security & Privacy

Information

Author
diet103
Updated
2026-01-30
Category
full-stack