Skip to content

qahtann/react-compiler-optimized-app

Repository files navigation

⚑ React Compiler Optimized App

React TypeScript Vite React Compiler

A production-ready, performance-focused demo application showcasing React Compiler's automatic memoization capabilities. This app demonstrates senior-level frontend engineering with advanced React 19 features, TypeScript rigor, performance profiling, and real-world optimizations.

🎯 Project Goals

  • Demonstrate React Compiler Benefits: Showcase automatic memoization, reduced re-renders, and performance improvements
  • Senior-Level Engineering: Advanced React patterns, strict TypeScript, accessibility, and best practices
  • GitHub-Ready: Professional UI, comprehensive documentation, and deployment-ready setup
  • 2026 Best Practices: Modern React Compiler integration and optimization techniques

✨ Features

πŸš€ Performance Optimizations

  • React Compiler Integration: Automatic memoization of components and functions
  • Virtualized Lists: TanStack Virtual for efficient rendering of 10k+ items
  • Performance Metrics: Real-time render counts, FPS, and render time tracking
  • Benchmarking Tools: Compare performance with compiler enabled vs disabled

πŸ“Š Demo Pages

  • Home: Overview and feature showcase
  • List Demo: Large virtualized list with search and filtering (10k items)
  • Chart Demo: Dynamic charts with real-time updates
  • Benchmark: Performance metrics and heavy component demos

🎨 UI/UX

  • Modern Design: Clean, professional interface with shadcn/ui components
  • Dark/Light Mode: System preference detection with manual toggle
  • Responsive: Mobile-first design that works on all screen sizes
  • Accessibility: ARIA labels, semantic HTML, keyboard navigation

πŸ› οΈ Tech Stack

  • React 19+ - Latest React with experimental Compiler support
  • React Compiler - Automatic memoization via babel-plugin-react-compiler
  • TypeScript - Strict mode, no any types, full type safety
  • Vite - Fast development and optimized builds
  • Tailwind CSS v4 - Utility-first styling
  • shadcn/ui - Beautiful, accessible component library
  • TanStack Query - Powerful data fetching and caching
  • TanStack Virtual - Efficient virtual scrolling
  • Recharts - Responsive chart visualizations
  • React Router - Client-side routing
  • Vitest - Fast unit testing

πŸ“Έ Screenshots

Screenshots will be added after deployment

  • Home page with feature overview
  • List demo with 10k virtualized items
  • Chart demo with real-time updates
  • Benchmark page with performance metrics

πŸš€ Getting Started

Prerequisites

  • Node.js 18+ and npm/yarn/pnpm
  • Git

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/react-compiler-optimized-app.git
    cd react-compiler-optimized-app
  2. Install dependencies

    npm install
  3. Set up environment variables

    cp .env.example .env

    Edit .env to enable React Compiler:

    VITE_ENABLE_COMPILER=true
  4. Start development server

    npm run dev

    The app will open at http://localhost:3000

Build for Production

npm run build
npm run preview

πŸ”§ React Compiler Setup

React Compiler is configured via environment variable and Babel plugin:

  1. Enable in .env:

    VITE_ENABLE_COMPILER=true
  2. Configuration (already set up in vite.config.ts):

    • Babel plugin: babel-plugin-react-compiler
    • Runtime module: react-compiler-runtime
    • Conditional loading based on env var
  3. Verify Compiler Status:

    • Check the badge in the header (shows "Compiler: ON/OFF")
    • Compare render counts in benchmark page

πŸ“Š Performance Benchmarks

With React Compiler Enabled

  • βœ… Automatic memoization of expensive computations
  • βœ… Reduced re-renders (visible in component render counts)
  • βœ… Improved FPS in benchmark tests
  • βœ… Lower average render times

Without React Compiler

  • Manual optimization required (useMemo, useCallback)
  • More re-renders for unchanged props
  • Higher render times for heavy components

πŸ§ͺ Testing

Run tests with Vitest:

# Run tests
npm test

# Run tests with UI
npm run test:ui

πŸ“ Project Structure

react-compiler-optimized-app/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/              # App entry point
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ ui/           # shadcn/ui components
β”‚   β”‚   β”œβ”€β”€ demo/         # Demo components
β”‚   β”‚   └── layout/       # Layout components
β”‚   β”œβ”€β”€ hooks/            # Custom hooks
β”‚   β”œβ”€β”€ lib/              # Utilities, types, API
β”‚   β”œβ”€β”€ pages/            # Route pages
β”‚   └── test/             # Test setup
β”œβ”€β”€ public/               # Static assets
β”œβ”€β”€ .env.example          # Environment variables template
β”œβ”€β”€ vite.config.ts        # Vite configuration
β”œβ”€β”€ tsconfig.json         # TypeScript configuration
└── tailwind.config.js    # Tailwind configuration

🚒 Deployment

Vercel (Recommended)

  1. Push to GitHub

    git push origin main
  2. Import to Vercel

    • Go to vercel.com
    • Import your GitHub repository
    • Add environment variable: VITE_ENABLE_COMPILER=true
    • Deploy!
  3. Environment Variables in Vercel

    • VITE_ENABLE_COMPILER: Set to true to enable React Compiler
    • VITE_API_BASE_URL: API base URL (optional)

Other Platforms

The app can be deployed to any static hosting service:

  • Netlify
  • GitHub Pages
  • Cloudflare Pages
  • AWS Amplify

πŸŽ“ Key Learnings

React Compiler Benefits

  1. Automatic Memoization: No need for manual useMemo/useCallback in most cases
  2. Reduced Re-renders: Components only re-render when props actually change
  3. Better Performance: Especially noticeable with heavy computations and large lists
  4. Cleaner Code: Less boilerplate, more readable components

Best Practices Demonstrated

  • Strict TypeScript configuration
  • Component composition and reusability
  • Performance profiling and monitoring
  • Accessibility (ARIA, semantic HTML)
  • Responsive design patterns
  • Error boundaries and loading states

πŸ™ Acknowledgments

πŸ“§ Contact

About

Performance-focused demo app leveraging React

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors