product management application built with React 19, React Router v7, Vite, and Tailwind CSS v4, optimized for Cloudflare Pages deployment.
- React 19 - Latest React with concurrent features (
useTransition,useOptimistic) - React Router v7 - Modern routing with lazy loading and error boundaries
- Vite 7 - Next-generation frontend tooling
- Tailwind CSS v4 - Utility-first CSS framework
- TypeScript - Type-safe development with strict mode
- Zod - Schema validation for forms and data
- React Hook Form - Performant form management with validation
- React Hot Toast - Beautiful toast notifications
- Lucide React - Modern icon library
- Cloudflare Pages - Edge deployment with Functions support
- β Full CRUD Operations - Create, read, update, and delete products
- π Advanced Filtering - Search by name, filter by category
- π Sorting - Sort by price, name, discount, stock, or date (ascending/descending)
- ποΈ Bulk Delete - Select and delete multiple products at once
- π·οΈ Product Variants - Support for product variants with price and stock modifiers
- πΈ Image Management - Multiple image URLs per product
- π·οΈ Tags & Categories - Organize products with tags and categories
- π° Discount Management - Set percentage-based discounts
- βοΈ Weight Tracking - Track product weight in grams
- β‘ Optimized Performance - Code splitting, lazy loading, and optimized builds
- π¨ Modern UI - Beautiful, responsive design with smooth animations
- π Dark Mode - Full dark mode support with theme persistence
- π React 19 Features - Uses
useTransitionfor non-urgent updates anduseOptimisticfor instant feedback - π± Responsive Design - Mobile-first approach with Tailwind CSS
- π Toast Notifications - User-friendly feedback for all actions
- β³ Loading States - Proper loading indicators and skeletons
- π‘οΈ Error Handling - Comprehensive error boundaries and error states
- π¦ Code Splitting - Route-based and component-based lazy loading
- π‘οΈ Type Safety - Full TypeScript support with strict mode
- π Fast Development - Hot module replacement and fast refresh
- π§ͺ Form Validation - Zod schemas with React Hook Form integration
- π Mock Data - Pre-configured mock products for development
- βοΈ Cloudflare Optimized - Configured for Cloudflare Pages deployment
# Install dependencies
pnpm installThe application works out of the box with default values. To customize, create a .env file:
VITE_APP_TITLE=Product Management
VITE_API_URL=https://api.example.com# Start development server
pnpm dev
# Type check
pnpm type-check
# Lint code
pnpm lint
# Fix linting issues
pnpm lint:fix
# Build for production
pnpm build
# Preview production build
pnpm previewThe project is configured for Cloudflare Pages deployment with optimized settings:
-
Using Wrangler CLI:
# Deploy to production pnpm deploy # Deploy to preview branch pnpm deploy:preview # Create a new Pages project pnpm pages:project:create # Test Pages Functions locally pnpm pages:dev
-
Using GitHub Actions:
- Push to
mainbranch - GitHub Actions will automatically build and deploy
- Configure secrets in GitHub:
CLOUDFLARE_API_TOKENCLOUDFLARE_ACCOUNT_ID
- Push to
-
Using Cloudflare Dashboard:
- Connect your GitHub repository
- Set build command:
pnpm build - Set output directory:
dist - Framework preset: React
- Deploy!
The project includes a middleware function (functions/_middleware.ts) that adds security headers to all responses. This works alongside the static _headers file for comprehensive security coverage.
React Router v7 is fully configured for Cloudflare Pages:
- SPA Routing: The
_redirectsfile ensures all routes serveindex.html, allowing React Router v7 to handle client-side routing - Middleware: Optimized to skip static assets and only process HTML responses
- Code Splitting: Routes are lazy-loaded for optimal performance
- Error Handling: Route-level error boundaries for graceful error handling
See CLOUDFLARE_REACT_ROUTER.md for detailed information about the React Router v7 + Cloudflare Pages setup.
src/
βββ components/ # Reusable UI components
β βββ ProductTable.tsx # Main product table with selection
β βββ ProductForm.tsx # Add/Edit product form with validation
β βββ ProductDetail.tsx # Product detail drawer
β βββ ProductFilters.tsx # Search, filter, and sort controls
β βββ DeleteModal.tsx # Single product delete confirmation
β βββ DeleteMultipleModal.tsx # Bulk delete confirmation
β βββ ThemeToggle.tsx # Dark mode toggle
β βββ ErrorBoundary.tsx # Error boundary component
β βββ LoadingFallback.tsx # Loading state component
βββ routes/ # React Router route components
β βββ index.tsx # Router configuration
β βββ home.tsx # Home page route (main product management)
βββ hooks/ # Custom React hooks
β βββ useProductManager.ts # Main product management logic
β βββ useTheme.ts # Theme context hook
βββ lib/ # Utility functions
β βββ env.ts # Environment variables
β βββ preload.ts # Preload utilities
βββ types/ # TypeScript type definitions
β βββ Product.ts # Product and filter types
βββ data/ # Data and mock data
β βββ mockProducts.ts # Mock product data for development
βββ context/ # React context providers
β βββ ThemeContext.tsx # Theme context (dark/light mode)
βββ styles/ # Global styles
β βββ index.css # Tailwind CSS and custom styles
βββ assets/ # Static assets
βββ react.svg
βββ placeholder-image.svg
- Code Splitting: Automatic route-based and component-based lazy loading
- Lazy Loading: ProductDetail, ProductForm, and modals loaded on demand
- Optimistic Updates: Using React 19's
useOptimisticfor instant UI feedback - Transition Management: Using
useTransitionfor non-urgent updates (drawer opens, filters) - Memoization: Strategic use of
useMemoanduseCallbackfor expensive operations - Debounced Search: Search input debounced to reduce unnecessary filtering
- Pagination: Virtual pagination with configurable items per page
- Asset Optimization: Optimized build output with proper chunking and tree shaking
- Path Aliases:
@/forsrc/directory (configured intsconfig.jsonandvite.config.ts) - TypeScript: Strict mode with comprehensive type checking
- ESLint: Code quality and consistency with TypeScript support
- Hot Module Replacement: Fast development feedback with Vite HMR
- Environment Variables: Type-safe environment configuration
- Mock Data: Pre-configured mock products for immediate development
- Headers Configuration: Security headers (CSP, XSS protection, frame options) and caching strategies
- Redirects: SPA routing support via
_redirectsfile - Middleware: Cloudflare Pages Functions middleware for dynamic header injection
- Build Optimization: Optimized for Cloudflare's edge network
- Asset Caching: Long-term caching for static assets (31536000s), no-cache for HTML
The application uses environment variables for configuration. Create a .env file in the root:
VITE_APP_TITLE=Product Management
VITE_API_URL=https://api.example.comEnvironment variables are type-safe and accessed via src/lib/env.ts.
The project uses path aliases for cleaner imports (configured in tsconfig.json and vite.config.ts):
import { ProductTable } from "@/components/ProductTable";
import { useProductManager } from "@/hooks/useProductManager";
import type { Product } from "@/types/Product";Tailwind CSS v4 is configured via tailwind.config.js and src/styles/index.css. The project uses:
- Custom color schemes
- Dark mode support
- Custom animations and transitions
- Responsive utilities
pnpm dev- Start development serverpnpm build- Build for productionpnpm build:analyze- Build with bundle analysispnpm preview- Preview production buildpnpm lint- Run ESLintpnpm lint:fix- Fix ESLint issuespnpm type-check- Type check without emittingpnpm clean- Clean build artifactspnpm deploy- Build and deploy to Cloudflare
The project uses Tailwind CSS v4 with:
- Custom Component Classes: Defined in
src/styles/index.css - Dark Mode: Full dark mode support with system preference detection
- Responsive Design: Mobile-first approach with breakpoint utilities
- Custom Animations: Smooth transitions for drawers, modals, and interactions
- Icon System: Lucide React icons for consistent iconography
- Theme Context: React Context API for theme management across the app
- X-Frame-Options: DENY (prevents clickjacking)
- X-Content-Type-Options: nosniff (prevents MIME sniffing)
- X-XSS-Protection: 1; mode=block (XSS protection)
- Referrer-Policy: strict-origin-when-cross-origin
- Permissions-Policy: Restricts geolocation, microphone, camera
- Zod Schemas: All form inputs validated with Zod schemas
- React Hook Form: Client-side validation with server-ready schemas
- Type Safety: TypeScript ensures type safety at compile time
- Static Assets: Long-term caching (1 year) with immutable flag
- HTML: No-cache with must-revalidate for always-fresh content
MIT