A modern, high-performance React application built with cutting-edge web development technologies. This project demonstrates the integration of React 19, TypeScript, Vite 6, Tailwind CSS v4, and Shadcn/UI components to create a scalable and maintainable frontend application.
π Prepared as a ready-to-use development kit by Yilmaz Emre Pala
- β‘ Lightning Fast: Powered by Vite 6 for instant development and optimized builds
- π‘οΈ Type Safety: Full TypeScript support with strict mode enabled
- π¨ Modern UI: Tailwind CSS v4 with Shadcn/UI components for beautiful interfaces
- π± Responsive Design: Mobile-first approach with responsive layouts
- π Hot Module Replacement: Instant updates during development
- π§ Client-side Routing: React Router v7 for seamless navigation
- π― Dynamic Title Management: Modern page title handling with custom hooks
- π¦ Optimized Bundle: Tree-shaking and code splitting for minimal bundle size
- π Code Quality: ESLint with React-specific rules and TypeScript integration
| Package | Version | Purpose |
|---|---|---|
| React | ^19.1.0 | Core library for building user interfaces with latest features |
| React DOM | ^19.1.0 | React rendering for web browsers |
| TypeScript | ~5.8.3 | Static type checking and enhanced developer experience |
| Vite | ^6.3.5 | Next-generation build tool for faster development |
| Package | Version | Purpose |
|---|---|---|
| Tailwind CSS | ^4.1.8 | Utility-first CSS framework for rapid UI development |
| @tailwindcss/vite | ^4.1.8 | Vite plugin for Tailwind CSS v4 integration |
| Shadcn/UI Components | - | Pre-built accessible UI components |
| @radix-ui/react-slot | ^1.2.3 | Primitive for creating flexible component APIs |
| Lucide React | ^0.513.0 | Beautiful & consistent icon library |
| Package | Version | Purpose |
|---|---|---|
| React Router DOM | ^7.6.2 | Declarative routing for React applications |
| Package | Version | Purpose |
|---|---|---|
| clsx | ^2.1.1 | Utility for constructing className strings conditionally |
| tailwind-merge | ^3.3.0 | Merge Tailwind CSS classes without style conflicts |
| class-variance-authority | ^0.7.1 | Create type-safe component variants |
| Package | Version | Purpose |
|---|---|---|
| @vitejs/plugin-react | ^4.4.1 | Official Vite plugin for React support |
| ESLint | ^9.25.0 | JavaScript/TypeScript linter for code quality |
| eslint-plugin-react-hooks | ^5.2.0 | ESLint rules for React Hooks |
| eslint-plugin-react-refresh | ^0.4.19 | ESLint plugin for React Fast Refresh |
| typescript-eslint | ^8.30.1 | TypeScript support for ESLint |
| @types/react | ^19.1.2 | TypeScript definitions for React |
| @types/react-dom | ^19.1.2 | TypeScript definitions for React DOM |
| @types/node | ^22.15.30 | TypeScript definitions for Node.js |
| tw-animate-css | ^1.3.4 | Tailwind CSS animations library |
| serve | ^14.2.4 | Static file server for production builds |
src/
βββ components/ # Reusable UI components
β βββ ui/ # Shadcn/UI components
βββ hooks/ # Custom React hooks
β βββ useDocumentMeta.ts # Dynamic title management
βββ pages/ # Page components
β βββ Home.tsx # Home page with counter example
β βββ About.tsx # About page with project info
βββ lib/ # Utility functions and configurations
βββ assets/ # Static assets (images, icons, etc.)
βββ App.tsx # Main application component with routing
βββ main.tsx # Application entry point
βββ index.css # Global styles and Tailwind imports
βββ vite-env.d.ts # Vite environment type definitions
- Node.js (version 18 or higher)
- npm or yarn package manager
-
Clone the repository
git clone <repository-url> cd react-vite-ts-tailwind-shadcn-ui
-
Install dependencies
npm install
-
Start development server
npm run dev
-
Open your browser Navigate to
http://localhost:5173to see the application
| Command | Description |
|---|---|
npm run dev |
Start development server with hot reload |
npm run build |
Build production-ready application |
npm run preview |
Preview production build locally |
npm run lint |
Run ESLint to check code quality |
npm run serve |
Serve production build on port 3000 |
This project uses Shadcn/UI components built on top of Radix UI primitives. To add new components:
npx shadcn@latest add [component-name]- Button: Multiple variants (default, outline, destructive, secondary)
- Icons: Lucide React icons integrated throughout the app
- Layout: Responsive grid and flexbox utilities
This project implements modern dynamic title and meta tag management using a powerful custom React hook. The useDocumentMeta hook provides comprehensive SEO optimization capabilities for your React applications.
- Dynamic Title Management: Update page titles based on route or component state
- Meta Tag Control: Manage description, keywords, and social media tags
- SEO Optimization: Improve search engine visibility with proper meta tags
- Social Media Ready: Automatic Open Graph and Twitter Card support
- TypeScript Support: Full type safety and IntelliSense
- Favicon Management: Dynamic favicon updates per page
- Template System: Flexible title formatting options
The main hook that handles all document meta management:
import { useDocumentMeta } from "@/hooks/useDocumentMeta";
const MyPage: React.FC = () => {
useDocumentMeta({
title: "Product Details",
description:
"Explore our amazing product with detailed specifications and customer reviews.",
keywords: ["product", "ecommerce", "reviews", "specifications"],
favicon: "/icons/product-favicon.ico",
image: "/images/product-social-share.jpg",
siteName: "My E-commerce Store",
separator: "β’",
});
return <div>Your page content...</div>;
};| Option | Type | Required | Description | Example |
| ------------- | ---------- | -------- | ------------------------ | ---------------------------------- | --- |
| title | string | β
| Page title | "Product Details" |
| description | string | β | Meta description for SEO | "Explore our amazing product..." |
| keywords | string[] | β | SEO keywords array | ["product", "ecommerce"] |
| favicon | string | β | Path to favicon | "/icons/favicon.ico" |
| image | string | β | Social sharing image | "/images/og-image.jpg" |
| siteName | string | β | Site/app name | "My App" |
| separator | string | β | Title separator | "β’" or " | " |
The template uses %s as a placeholder for the page title:
useDocumentMeta({
title: "Home",
siteName: "My React App",
separator: "|",
});
// Result: "Home | My React App"useDocumentMeta({
title: "React Development Services",
description:
"Professional React development services with modern tools and best practices. Contact us for your next project.",
keywords: ["React", "development", "services", "TypeScript", "modern web"],
siteName: "DevCorp Solutions",
separator: "β’",
});const ProductPage: React.FC = () => {
const { product } = useParams();
useDocumentMeta({
title: `${product?.name} - Product Details`,
description: product?.description,
keywords: product?.tags,
image: product?.featuredImage,
siteName: "E-Commerce Store",
});
return <div>Product details...</div>;
};const BlogPost: React.FC = () => {
const { post } = useLoaderData();
useDocumentMeta({
title: post.title,
description: post.excerpt,
keywords: [...post.tags, "blog", "article"],
image: post.featuredImage,
siteName: "Tech Blog",
separator: "β",
});
return <article>...</article>;
};- Keep titles between 50-60 characters
- Include primary keywords near the beginning
- Make titles descriptive and unique per page
- Use consistent separators across your site
- Aim for 150-160 characters
- Write compelling, actionable descriptions
- Include target keywords naturally
- Each page should have a unique description
- Use 3-8 relevant keywords per page
- Include both short-tail and long-tail keywords
- Avoid keyword stuffing
- Research competitor keywords
- Use high-quality images (1200x630px for Open Graph)
- Ensure images are optimized for web
- Test social sharing previews
- Include branded elements in social images
Visit the Example Components page in the application to see the hook in action with:
- β Live meta tag updates
- β Interactive code examples
- β TypeScript integration
- β Best practices guide
- β Real-time preview of changes
Navigate to /example-components to explore comprehensive usage examples and see how the hook dynamically updates your page's meta information.
The hook is fully typed for enhanced developer experience:
interface DocumentMetaOptions {
title: string;
description?: string;
keywords?: string[];
favicon?: string;
image?: string;
siteName?: string;
separator?: string;
template?: string;
}
// Full type safety and IntelliSense support
const useDocumentMeta: (options: DocumentMetaOptions) => void;- The hook uses
useEffectto update the document head - Meta tags are updated on component mount and when dependencies change
- Previous meta tags are automatically cleaned up
- Works seamlessly with React Router for SPA navigation
- Compatible with SSR frameworks (Next.js, Remix, etc.)
The application is built with a mobile-first approach using Tailwind CSS:
- Mobile: Base styles
- Tablet:
md:prefix (768px+) - Desktop:
lg:prefix (1024px+) - Large Desktop:
xl:prefix (1280px+)
The project uses a comprehensive ESLint setup with:
- React-specific rules for hooks and JSX
- TypeScript integration for type checking
- React Refresh support for fast development
- Modern JavaScript standards (ES2022+)
- Strict mode enabled for maximum type safety
- Path mapping configured for clean imports (
@/prefix) - Modern target (ES2022) for optimal performance
- Fast HMR: Instant updates during development
- Optimized builds: Tree-shaking and code splitting
- Asset optimization: Automatic image and font optimization
- ES modules: Modern JavaScript module system
- React 19 features: Latest React optimizations
- Code splitting: Automatic route-based splitting
- Tree shaking: Unused code elimination
npm run buildThis creates an optimized build in the dist/ directory with:
- Minified JavaScript and CSS
- Optimized assets
- Gzipped files for faster loading
- Source maps for debugging
npm run serveServes the production build locally on port 3000.
- Vercel: Zero-config deployment
- Netlify: Drag-and-drop deployment
- GitHub Pages: Static site hosting
- Traditional hosting: Upload
dist/folder
Since this is a Single Page Application (SPA) with client-side routing, you need to configure your web server to serve index.html for all routes to prevent 404 errors when users navigate directly to routes like /about.
For Apache Servers (.htaccess)
# SPA Routing - Main configuration
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/api/
RewriteRule . /index.html [L]
# Cache settings for better performance
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
</IfModule>
# Gzip compression for faster loading
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>
# Security headers
<IfModule mod_headers.c>
Header always set X-Content-Type-Options nosniff
Header always set X-Frame-Options DENY
Header always set X-XSS-Protection "1; mode=block"
</IfModule>For Netlify (_redirects)
# Netlify redirects for SPA routing
/* /index.html 200
# API redirects (if needed)
/api/* https://your-api-domain.com/api/:splat 200
Why These Files Are Critical:
-
Without .htaccess or _redirects: When users navigate directly to
/aboutor refresh the page, the server returns a 404 error because it's looking for a physical file that doesn't exist. -
With proper configuration: The server redirects all non-file requests to
index.html, allowing React Router to handle the routing client-side. -
Performance benefits: The configuration includes caching rules and gzip compression for optimal loading speeds.
-
Security enhancements: Additional security headers protect against common web vulnerabilities.
Setup Instructions:
- Apache hosting: Place the
.htaccessfile in yourdist/folder before uploading - Netlify: Place the
_redirectsfile in yourdist/folder or use Netlify's dashboard - Other platforms: Check platform-specific documentation for SPA routing configuration
- Create a new component in
src/pages/ - Add route to
src/App.tsx - Implement dynamic title with
useDocumentMeta
- Create component in
src/components/ - Use Shadcn/UI components as base
- Apply Tailwind CSS for styling
- Modify
src/index.cssfor global styles - Use Tailwind CSS utility classes
- Create custom CSS variables for theming
- Port already in use: Change port in
vite.config.ts - TypeScript errors: Check
tsconfig.jsonconfiguration - Import errors: Verify path mapping in
tsconfig.json - Build errors: Check for unused imports and dependencies
- Use TypeScript strictly for better error catching
- Leverage Vite's HMR for faster development
- Use React DevTools for debugging
- Follow React best practices and hooks rules
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linting
- Submit a pull request
This project is open source and available under the MIT License.
- React Team for the amazing framework
- Vite Team for the incredible build tool
- Tailwind CSS for the utility-first approach
- Shadcn for the beautiful UI components
- Radix UI for accessible primitives