Skip to content

hetGE/my-next-app

Repository files navigation

Next.js Modern Template

A production-ready Next.js template with TypeScript, Tailwind CSS, and best practices built-in. Perfect for building modern web applications quickly and efficiently.

✨ Features

  • Next.js 15 - Latest version with App Router
  • TypeScript - Type-safe development experience
  • Tailwind CSS v4 - Utility-first CSS framework
  • Dark Mode - Built-in dark mode support with system preference detection
  • Responsive Design - Mobile-first, fully responsive components
  • SEO Optimized - Meta tags, Open Graph, and structured data ready
  • Performance - Optimized for Core Web Vitals
  • Developer Experience - Fast Refresh, ESLint, Prettier pre-configured
  • Production Ready - Best practices and scalable architecture

πŸš€ Quick Start

Prerequisites

  • Node.js 18.17 or later
  • pnpm, npm, yarn, or bun package manager

Installation

  1. Use this template (recommended):

    # Click "Use this template" button on GitHub
    # Or clone directly
    git clone https://github.com/yourusername/your-repo-name.git
    cd your-repo-name
  2. Install dependencies:

    pnpm install
    # or
    npm install
    # or
    yarn install
  3. Run the development server:

    pnpm dev
    # or
    npm run dev
    # or
    yarn dev
  4. Open your browser: Navigate to http://localhost:3000

πŸ“ Project Structure

my-next-app/
β”œβ”€β”€ app/                  # App Router directory
β”‚   β”œβ”€β”€ api/             # API routes
β”‚   β”‚   └── hello/       # Example API endpoint
β”‚   β”œβ”€β”€ error.tsx        # Error boundary
β”‚   β”œβ”€β”€ global-error.tsx # Root error boundary
β”‚   β”œβ”€β”€ layout.tsx       # Root layout
β”‚   β”œβ”€β”€ loading.tsx      # Loading state
β”‚   β”œβ”€β”€ not-found.tsx    # 404 page
β”‚   β”œβ”€β”€ page.tsx         # Home page
β”‚   β”œβ”€β”€ robots.txt       # SEO robots file
β”‚   β”œβ”€β”€ sitemap.ts       # Dynamic sitemap
β”‚   └── globals.css      # Global styles
β”œβ”€β”€ components/          # React components
β”‚   β”œβ”€β”€ layout/         # Layout components
β”‚   β”‚   β”œβ”€β”€ header.tsx  # Site header with navigation
β”‚   β”‚   └── footer.tsx  # Site footer
β”‚   └── ui/             # UI components
β”‚       β”œβ”€β”€ button.tsx  # Button component
β”‚       β”œβ”€β”€ card.tsx    # Card component
β”‚       β”œβ”€β”€ input.tsx   # Input component
β”‚       └── skeleton.tsx # Skeleton loaders
β”œβ”€β”€ hooks/               # Custom React hooks
β”‚   β”œβ”€β”€ use-debounce.ts # Debounce hook
β”‚   β”œβ”€β”€ use-local-storage.ts # LocalStorage hook
β”‚   └── use-media-query.ts # Media query hook
β”œβ”€β”€ utils/               # Utility functions
β”‚   β”œβ”€β”€ cn.ts           # Class name merger
β”‚   └── format.ts       # Formatting utilities
β”œβ”€β”€ types/               # TypeScript definitions
β”‚   └── global.d.ts     # Global type definitions
β”œβ”€β”€ public/              # Static assets
β”œβ”€β”€ .github/             # GitHub templates
β”‚   β”œβ”€β”€ workflows/      # GitHub Actions
β”‚   └── ISSUE_TEMPLATE/ # Issue templates
β”œβ”€β”€ .vscode/             # VS Code configuration
β”œβ”€β”€ middleware.ts        # Next.js middleware
β”œβ”€β”€ CLAUDE.md            # AI assistant guidelines
β”œβ”€β”€ LICENSE              # MIT license
└── ...config files      # Various configuration files

Note: The template supports Next.js routing conventions including route groups (auth), dynamic routes [id], and catch-all routes [...slug].

πŸ› οΈ Customization Guide

1. Update Metadata

Edit app/layout.tsx to update your site's metadata:

export const metadata: Metadata = {
  title: "Your Site Title",
  description: "Your site description",
};

2. Modify Color Scheme

Update the CSS variables in app/globals.css:

:root {
  --background: #ffffff;
  --foreground: #171717;
}

3. Configure Tailwind

Customize your design system in tailwind.config.js (if using Tailwind v3) or through CSS variables.

4. Add Environment Variables

Create a .env.local file for your environment variables:

NEXT_PUBLIC_API_URL=your_api_url
DATABASE_URL=your_database_url

🧩 Built-in Components

UI Components

  • Button - Versatile button with multiple variants (primary, secondary, outline, ghost, danger)
  • Card - Container component with header, content, and footer sections
  • Input - Form input with label, error, and helper text support
  • Skeleton - Loading placeholders with multiple variants (text, circular, rectangular)

Layout Components

  • Header - Responsive navigation header with mobile menu
  • Footer - Full-featured footer with newsletter signup

Usage Example

import { Button } from "@/components/ui/button";
import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card";

<Card>
  <CardHeader>
    <CardTitle>Welcome</CardTitle>
  </CardHeader>
  <CardContent>
    <Button variant="primary" size="lg">Get Started</Button>
  </CardContent>
</Card>

πŸͺ Custom Hooks

Available Hooks

  • useLocalStorage - Persist state to localStorage with SSR safety
  • useMediaQuery - Responsive design with media query support
  • useDebounce - Debounce values for optimized performance

Usage Example

import { useLocalStorage } from "@/hooks/use-local-storage";
import { useMediaQuery } from "@/hooks/use-media-query";
import { useDebounce } from "@/hooks/use-debounce";

function MyComponent() {
  const [theme, setTheme] = useLocalStorage("theme", "light");
  const isMobile = useMediaQuery("(max-width: 640px)");
  const debouncedSearch = useDebounce(searchTerm, 500);
}

πŸ›‘οΈ Middleware

The template includes middleware with:

  • Security headers (X-Frame-Options, CSP, etc.)
  • Maintenance mode support
  • Authentication examples (commented)
  • Geolocation routing examples
  • A/B testing setup

πŸ“œ Available Scripts

  • pnpm dev - Start development server with Turbopack
  • pnpm build - Build for production
  • pnpm start - Start production server
  • pnpm lint - Run ESLint
  • pnpm typecheck - Run TypeScript type checking

πŸ”§ Tech Stack

πŸš€ Deployment

Vercel (Recommended)

The easiest way to deploy your Next.js app:

Deploy with Vercel

  1. Push your code to GitHub
  2. Import your repository in Vercel
  3. Deploy with zero configuration

Other Platforms

🎯 Best Practices

Code Organization

  • Keep components small and focused
  • Use TypeScript interfaces for props
  • Implement proper error boundaries
  • Follow the Next.js file-based routing conventions

Performance

  • Use Next.js Image component for optimized images
  • Implement lazy loading for heavy components
  • Utilize Next.js font optimization

SEO

  • Use semantic HTML elements
  • Implement proper meta tags
  • Add structured data for rich snippets
  • Create a sitemap.xml and robots.txt

Security

  • Validate all user inputs
  • Use environment variables for sensitive data
  • Implement proper CORS policies
  • Keep dependencies updated

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes using conventional commits with emojis (see CLAUDE.md for format)
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Note: Please refer to CLAUDE.md for coding standards and commit conventions.

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ“š Learn More

To learn more about the technologies used in this template:

πŸ’¬ Support

For support, please open an issue in the GitHub repository or reach out to the community.


Built with ❀️ using Next.js

About

Next.js Modern Template

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors