Skip to content

A production-ready Next.js 15 starter template with TypeScript, featuring a modern development stack with state management, API handling, and comprehensive tooling setup.

Notifications You must be signed in to change notification settings

dvsxdev/next-ts

Repository files navigation

Next.js TypeScript Starter Template

A production-ready Next.js 15 starter template with TypeScript, featuring a modern development stack with state management, API handling, and comprehensive tooling setup.

πŸš€ Features

  • ⚑ Next.js 15 with App Router
  • πŸ”· TypeScript for type safety
  • 🎨 Tailwind CSS v4 for styling
  • 🧩 shadcn/ui components with Radix UI primitives
  • πŸ”„ Redux Toolkit for state management
  • πŸ” TanStack Query (React Query) for server state management
  • πŸ“Š TanStack Table for data tables
  • 🌐 Axios with interceptors for API calls
  • βœ… Zod for schema validation
  • πŸ“¦ Lucide React for icons
  • πŸ”§ ESLint & Prettier for code quality
  • πŸ• Husky for Git hooks

πŸ› οΈ Tech Stack

Core Framework

  • Next.js - React framework with App Router
  • React - UI library
  • TypeScript - Type safety

Styling & UI

  • Tailwind CSS v4 - Utility-first CSS framework
  • shadcn/ui - Reusable UI components

State Management

  • Redux Toolkit - State management
  • React Redux - React bindings for Redux
  • TanStack Query - Server state management

Data & API

  • Axios - HTTP client with interceptors
  • Zod - Schema validation
  • TanStack Table - Data tables

Development Tools

  • ESLint - Code linting
  • Prettier - Code formatting
  • Husky - Git hooks
  • lint-staged - Run linters on staged files

πŸ“ Folder Structure

next-ts/
β”œβ”€β”€ public/                    # Static assets
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/                   # Next.js App Router
β”‚   β”‚   β”œβ”€β”€ favicon.ico
β”‚   β”‚   β”œβ”€β”€ globals.css        # Global styles
β”‚   β”‚   β”œβ”€β”€ layout.tsx         # Root layout
β”‚   β”‚   └── page.tsx           # Home page
β”‚   β”œβ”€β”€ components/            # Reusable components
β”‚   β”‚   └── ui/                # shadcn/ui components
β”‚   β”‚       └── button.tsx
β”‚   β”œβ”€β”€ config/                # App configuration
β”‚   β”‚   └── index.ts           # Environment variables & constants
β”‚   β”œβ”€β”€ lib/                   # Utilities & configurations
β”‚   β”‚   β”œβ”€β”€ axios.ts           # Axios setup with interceptors
β”‚   β”‚   └── utils.ts           # Utility functions
β”‚   β”œβ”€β”€ provider/              # Context providers
β”‚   β”‚   β”œβ”€β”€ app.tsx            # App provider
β”‚   β”‚   β”œβ”€β”€ index.tsx          # Combined providers
β”‚   β”‚   β”œβ”€β”€ query.tsx          # TanStack Query provider
β”‚   β”‚   └── store.tsx          # Redux store provider
β”‚   β”œβ”€β”€ schemas/               # Zod validation schemas
β”‚   β”‚   └── user.ts            # User schema
β”‚   β”œβ”€β”€ services/              # API service layer
β”‚   β”‚   └── user.ts            # User API services
β”‚   └── store/                 # Redux store setup
β”‚       β”œβ”€β”€ index.ts           # Store configuration
β”‚       └── slice/             # Redux slices
β”‚           └── user.ts        # User slice
β”œβ”€β”€ .gitignore                 # Git ignore rules
β”œβ”€β”€ .husky/                    # Husky Git hooks
β”‚   └── pre-commit            # Pre-commit hook
β”œβ”€β”€ .prettierignore           # Prettier ignore rules
β”œβ”€β”€ .prettierrc               # Prettier configuration
β”œβ”€β”€ components.json           # shadcn/ui configuration
β”œβ”€β”€ eslint.config.mjs         # ESLint configuration
β”œβ”€β”€ next.config.ts            # Next.js configuration
β”œβ”€β”€ package.json              # Dependencies & scripts
β”œβ”€β”€ postcss.config.mjs        # PostCSS configuration
β”œβ”€β”€ tailwind.config.ts        # Tailwind CSS configuration
└── tsconfig.json             # TypeScript configuration

🚦 Getting Started

Prerequisites

  • Node.js 22+
  • npm, yarn, or pnpm

Installation

  1. Clone the repository

    git clone https://github.com/dvsxdev/next-ts.git
    cd next-ts
  2. Install dependencies

    npm install
    # or
    yarn install
    # or
    pnpm install
  3. Set up environment variables Copy .env.example to .env and update the values:

    NEXT_PUBLIC_APP_NAME=Your App Name
    NEXT_PUBLIC_API_URL=http://127.0.0.1:8000
  4. Run the development server

    npm run dev
  5. Open your browser Navigate to http://localhost:3000

πŸ“œ Available Scripts

Script Description
npm run dev Start development server
npm run build Build for production
npm run start Start production server
npm run lint:check Check for linting errors
npm run lint:fix Fix linting errors
npm run format:check Check code formatting
npm run format:fix Fix code formatting
npm run prepare Set up Husky Git hooks

βš™οΈ Configuration

TypeScript

  • Path mapping configured for @/* imports
  • Strict mode enabled
  • Modern ES2017 target

ESLint

  • Next.js core web vitals rules
  • TypeScript support
  • TanStack Query plugin for best practices

Prettier

  • Consistent code formatting
  • Integrated with lint-staged

Tailwind CSS

  • Tailwind CSS v4
  • PostCSS integration
  • shadcn/ui compatible

shadcn/ui

  • React Server Components support
  • Lucide icons
  • Gray base color with CSS variables

πŸ”§ Key Features Explained

State Management

  • Redux Toolkit: Global state management with user slice
  • TanStack Query: Server state, caching, and synchronization

API Layer

  • Axios Configuration: Pre-configured with base URL and interceptors
  • Authentication: Automatic token attachment and 401 handling
  • Cookie Management: Secure token storage

Type Safety

  • Zod Schemas: Runtime validation with TypeScript inference
  • TypeScript: Comprehensive type coverage

Code Quality

  • Husky: Pre-commit hooks for code quality
  • lint-staged: Run linters only on changed files
  • ESLint + Prettier: Consistent code style

UI Components

  • shadcn/ui: Copy-paste component system
  • Radix UI: Accessible, unstyled components
  • Tailwind CSS: Utility-first styling

πŸ”„ Development Workflow

  1. Feature Development: Create components in src/components/
  2. State Management: Add slices in src/store/slice/
  3. API Services: Define services in src/services/
  4. Validation: Create schemas in src/schemas/
  5. Styling: Use Tailwind classes and shadcn/ui components

πŸ“¦ Adding New Dependencies

UI Components

npx shadcn@latest add [component-name]

Icons

# Lucide icons are included
import { IconName } from "lucide-react"
``

## πŸ“„ License

This project is licensed under the MIT License.

About

A production-ready Next.js 15 starter template with TypeScript, featuring a modern development stack with state management, API handling, and comprehensive tooling setup.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published