a233894432 / nextjs-Example

nextjs-Example

Repository from Github https://github.coma233894432/nextjs-ExampleRepository from Github https://github.coma233894432/nextjs-Example

Next.js TypeScript Starter Template

A production-ready, scalable, and actively maintained starter template for building high-quality web apps with Next.js, TypeScript, and Tailwind CSS.


next-ts-app version License MIT

Nextjs TypeScript Tailwind CSS ESLint Prettier Husky


πŸš€ Why Use This Template?

This starter template is designed for developers of all levels β€” from beginners starting their journey to advanced engineers building scalable applications.

Key Features

  • ⚑️ Next.js 15+ with App Router
  • βœ… TypeScript – full type safety and custom config
  • 🎨 Tailwind CSS – preconfigured and responsive
  • 🧹 ESLint + Prettier – clean, consistent code
  • πŸ” Husky + lint-staged – prevent bad commits
  • 🌿 Scalable folder structure – production standard
  • πŸ“¦ Alias support – easy path management
  • πŸ§ͺ Ready for unit & integration testing
  • ☁️ Vercel ready – just push and deploy

How to Start

Option 1: Create with CLI (Recommended)

Quickly set up your Next.js + TypeScript + TailwindCSS project using the CLI tool:

  • πŸ“¦ using npm
    npx next-ts-app my-awesome-app
  • Replace my-awesome-app with your desired project name.
  • The CLI will scaffold a fully configured Next.js + TypeScript + TailwindCSS starter for you.

βœ… Fast | πŸ”§ Pre-configured | πŸ§ͺ Ready for development


CLI Options

During project creation, you'll be prompted to:

  1. Project Name: Enter a name for your project (e.g., my-awesome-app)

  2. Package Manager: Choose your preferred package manager:

    • bun (Recommended for speed)
    • npm (Most common)
    • yarn (Alternative to npm)
    • pnpm (Fast, disk-space efficient)
  3. Follow the steps shown: For example, if you choose bun:

    cd my-awesome-project
    bun install
    bun run dev

    Note: If you pick bun, make sure Bun is installed (npm install -g bun or visit bun.sh). For pnpm or yarn, install them first if needed.

Available Scripts

The project includes several useful scripts:

# Development
bun run dev          # Start development server with Turbopack
bun run build        # Create production build
bun run start        # Start production server
bun run lint         # Run ESLint
bun run lint:fix     # Fix ESLint errors
bun run format       # Format code with Prettier
bun run format:check # Check code formatting
bun run clear-cache  # Clear Next.js cache, reinstall dependencies, and restart dev server

The clear-cache script is particularly useful when you encounter build issues or need to reset your development environment. It:

  1. Removes the .next directory
  2. Reinstalls dependencies without using cache
  3. Restarts the development server

Prerequisites

  • For Bun: Install via npm install -g bun
  • For pnpm: Install via npm install -g pnpm
  • For Yarn: Install via npm install -g yarn
  • For npm: Comes with Node.js

What's Included

After installation, you'll get:

  • βœ… Next.js 15 with App Router
  • βœ… TypeScript configuration
  • βœ… Tailwind CSS setup
  • βœ… ESLint & Prettier
  • βœ… Git hooks with Husky
  • βœ… Project structure ready to go

Option 2: Use GitHub Template

  1. Click Use this template on GitHub.

  2. Name your new repository.

  3. Click Create repository.

  4. Set up locally:

    git clone https://github.com/[your-username]/[your-repo].git
    cd [your-repo]
    bun install
    bun run dev

Project Structure

public/                      # Public static assets that are served directly
β”œβ”€β”€ assets/                  # Static assets directory
β”‚   β”œβ”€β”€ images/             # Image files (png, jpg, svg, etc.)
β”‚   └── data/               # Static JSON data files
β”‚
src/                        # Source code directory
β”œβ”€β”€ app/                    # Next.js 13+ App Router directory
β”‚   β”œβ”€β”€ (landing)/         # Landing page route group (optional)
β”‚   β”‚   β”œβ”€β”€ _components/    # Page-specific components
β”‚   β”‚   β”œβ”€β”€ error.tsx      # Error boundary for landing page
β”‚   β”‚   β”œβ”€β”€ loading.tsx    # Loading state for landing page
β”‚   β”‚   └── page.tsx       # Landing page entry point
β”‚   β”‚
β”‚   β”œβ”€β”€ (dashboard)/       # Dashboard route group
β”‚   β”‚   β”œβ”€β”€ _components/    # Dashboard-specific components
β”‚   β”‚   β”œβ”€β”€ error.tsx      # Error boundary for dashboard
β”‚   β”‚   β”œβ”€β”€ loading.tsx    # Loading state for dashboard
β”‚   β”‚   └── page.tsx       # Dashboard page entry
β”‚   β”‚
β”‚   β”œβ”€β”€ layout.tsx         # Root layout (shared across all pages)
β”‚   β”œβ”€β”€ template.tsx       # Template for per-page layouts
β”‚   └── providers.tsx      # Global context providers (Theme, Auth, etc.)
β”‚
β”œβ”€β”€ components/            # Reusable components directory
β”‚   β”œβ”€β”€ ui/               # UI primitives (buttons, inputs, cards)
β”‚   β”‚   β”œβ”€β”€ button.tsx    # Button component
β”‚   β”‚   β”œβ”€β”€ input.tsx     # Input component
β”‚   β”‚   └── card.tsx      # Card component
β”‚   β”‚
β”‚   β”œβ”€β”€ layout/           # Layout components
β”‚   β”‚   β”œβ”€β”€ header.tsx    # Header component
β”‚   β”‚   β”œβ”€β”€ footer.tsx    # Footer component
β”‚   β”‚   └── sidebar.tsx   # Sidebar component
β”‚   β”‚
β”‚   β”œβ”€β”€ shared/           # Shared components across features
β”‚   β”‚   β”œβ”€β”€ ThemeToggle.tsx  # Theme toggle component
β”‚   β”‚   └── Analytics.tsx    # Analytics component
β”‚   β”‚
β”‚   β”œβ”€β”€ forms/            # Form-related components
β”‚   β”‚   β”œβ”€β”€ FormInput.tsx    # Form input component
β”‚   β”‚   └── FormSelect.tsx   # Form select component
β”‚   β”‚
β”‚   └── icons/            # SVG icon components
β”‚       β”œβ”€β”€ index.tsx     # Icon exports
β”‚       └── SocialIcons/  # Social media icons
β”‚
β”œβ”€β”€ config/               # Application configuration
β”‚   β”œβ”€β”€ site.ts          # Site metadata and configuration
β”‚   β”œβ”€β”€ routes.ts        # Route definitions and constants
β”‚   └── theme.ts         # Theme configuration and tokens
β”‚
β”œβ”€β”€ hooks/               # Custom React hooks
β”‚   β”œβ”€β”€ useAuth.ts       # Authentication hook
β”‚   β”œβ”€β”€ useAnalytics.ts  # Analytics hook
β”‚   β”œβ”€β”€ useDebounce.ts   # Debounce utility hook
β”‚   └── useLocalStorage.ts # Local storage hook
β”‚
β”œβ”€β”€ lib/                 # Utility libraries and helpers
β”‚   β”œβ”€β”€ api/            # API client configurations
β”‚   β”‚   β”œβ”€β”€ axios.ts    # Axios instance and interceptors
β”‚   β”‚   └── trpc/       # tRPC client setup
β”‚   β”‚
β”‚   β”œβ”€β”€ utils/          # Utility functions
β”‚   β”‚   β”œβ”€β”€ formatter.ts # Data formatting utilities
β”‚   β”‚   └── validators.ts # Validation utilities
β”‚   β”‚
β”‚   └── constants.ts    # Application constants
β”‚
β”œβ”€β”€ styles/             # Global styles and CSS
β”‚   β”œβ”€β”€ globals.css     # Global CSS styles
β”‚   β”œβ”€β”€ theme/          # Theme variables and tokens
β”‚   └── components/     # Component-specific styles
β”‚
β”œβ”€β”€ types/              # TypeScript type definitions
β”‚   β”œβ”€β”€ index.d.ts      # Global type declarations
β”‚   β”œβ”€β”€ next.d.ts       # Next.js type extensions
β”‚   └── custom-types.ts # Custom type definitions
β”‚
β”œβ”€β”€ services/           # Business logic and services
β”‚   β”œβ”€β”€ auth.service.ts    # Authentication service
β”‚   └── analytics.service.ts # Analytics service
β”‚
β”œβ”€β”€ contexts/           # React Context providers
β”‚   β”œβ”€β”€ ThemeContext.tsx  # Theme context
β”‚   └── AuthContext.tsx   # Authentication context
β”‚
└── __tests__/         # Test files directory
    β”œβ”€β”€ components/     # Component tests
    β”œβ”€β”€ hooks/         # Hook tests
    β”œβ”€β”€ services/      # Service tests
    └── utils/         # Utility function tests

Code Quality Tools

These tools keep your code neat:

  • ESLint: Finds code mistakes.
  • Prettier: Formats code nicely.
  • Tailwind CSS: Organizes styles.
  • Husky: Checks code before commits.
  • lint-staged: Runs checks on changed files.

Example rule for imports:

"import/order": [
  "error",
  {
    "groups": ["builtin", "external", "internal"],
    "alphabetize": { "order": "asc" }
  }
]

Deployment

This template works with:

  • Vercel
  • Netlify
  • AWS
  • Docker

Copy .env.example to .env for production settings.

Developer & Contributor

Salman Ahamed
Salman Ahamed
GitHub | LinkedIn | Email
Eyachir Arafat
Eyachir Arafat
GitHub | LinkedIn | Portfolio
Md Amzad Hossain Omor
Md Amzad Hossain
GitHub | LinkedIn | Email
Hasibul Alam
Hasibul Alam
GitHub | LinkedIn | Email

Want to Help?

Check our CONTRIBUTING GUIDE to contribute.

License

Free to use under MIT License. See the LICENSE file for details.

About

nextjs-Example

License:MIT License


Languages

Language:TypeScript 93.4%Language:JavaScript 4.4%Language:Shell 1.1%Language:CSS 1.1%