Skip to content

trhgatu/inf-nextjs-frontend-template

Repository files navigation

βš”οΈ trhgatu-inf-nextjs-frontend-template

Next.js TypeScript TailwindCSS Redux

A modern, production-ready Next.js 14 template with TypeScript, TailwindCSS, ShadCN/UI, Redux Toolkit, and automated CI/CD pipeline.

πŸš€ Quick Start β€’ πŸ“– Documentation β€’ 🀝 Contributing β€’ πŸ’¬ Support


✨ Features

πŸ—οΈ Architecture

  • Next.js 14 App Router
  • TypeScript for type safety
  • Modular folder structure
  • Feature-based organization

🎨 UI/Styling

  • TailwindCSS utility-first
  • ShadCN/UI components
  • Responsive design
  • Dark mode ready

⚑ State Management

  • Redux Toolkit setup
  • Async thunks configured
  • Type-safe hooks
  • Persistent state

πŸ› οΈ Developer Experience

  • ESLint + Prettier
  • Husky git hooks
  • GitHub Actions CI/CD
  • Hot reload

🧠 Tech Stack

Category Technologies
Framework Next.js 14 (App Router)
Language TypeScript
Styling TailwindCSS, ShadCN/UI
State Management Redux Toolkit, RTK Query
HTTP Client Axios
Validation Zod
Testing Jest, React Testing Library
Linting ESLint, Prettier
CI/CD GitHub Actions

πŸ“ Project Structure

trhgatu-inf-nextjs-frontend-template/
β”œβ”€β”€ πŸ“ src/
β”‚   β”œβ”€β”€ πŸ“ app/                    # Next.js App Router
β”‚   β”‚   β”œβ”€β”€ πŸ“„ layout.tsx          # Root layout
β”‚   β”‚   β”œβ”€β”€ πŸ“„ page.tsx            # Home page
β”‚   β”‚   β”œβ”€β”€ πŸ“„ loading.tsx         # Global loading UI
β”‚   β”‚   β”œβ”€β”€ πŸ“„ not-found.tsx       # 404 page
β”‚   β”‚   └── πŸ“ (auth)/             # Auth route group
β”‚   β”‚       └── πŸ“„ login/page.tsx  # Login page
β”‚   β”œβ”€β”€ πŸ“ components/
β”‚   β”‚   β”œβ”€β”€ πŸ“ shared/             # Reusable components
β”‚   β”‚   β”‚   β”œβ”€β”€ πŸ“„ Navbar.tsx      # Navigation component
β”‚   β”‚   β”‚   └── πŸ“„ Footer.tsx      # Footer component
β”‚   β”‚   └── πŸ“ ui/                 # ShadCN UI components
β”‚   β”œβ”€β”€ πŸ“ config/                 # Configuration files
β”‚   β”‚   └── πŸ“„ site.ts             # Site configuration
β”‚   β”œβ”€β”€ πŸ“ constants/              # Application constants
β”‚   β”‚   └── πŸ“„ routes.ts           # Route definitions
β”‚   β”œβ”€β”€ πŸ“ features/               # Feature modules
β”‚   β”‚   └── πŸ“ auth/               # Authentication feature
β”‚   β”‚       β”œβ”€β”€ πŸ“„ hooks.ts        # Auth hooks
β”‚   β”‚       β”œβ”€β”€ πŸ“„ services.ts     # Auth API services
β”‚   β”‚       └── πŸ“„ schemas.ts      # Validation schemas
β”‚   β”œβ”€β”€ πŸ“ lib/                    # Utility libraries
β”‚   β”‚   β”œβ”€β”€ πŸ“„ axios.ts            # Axios configuration
β”‚   β”‚   └── πŸ“„ utils.ts            # Helper functions
β”‚   β”œβ”€β”€ πŸ“ store/                  # Redux store
β”‚   β”‚   β”œβ”€β”€ πŸ“„ index.ts            # Store configuration
β”‚   β”‚   β”œβ”€β”€ πŸ“„ provider.tsx        # Redux provider
β”‚   β”‚   └── πŸ“ slices/             # Redux slices
β”‚   └── πŸ“ types/                  # TypeScript definitions
β”œβ”€β”€ πŸ“ .github/workflows/          # GitHub Actions
β”‚   └── πŸ“„ ci.yml                  # CI/CD pipeline
β”œβ”€β”€ πŸ“„ next.config.ts              # Next.js configuration
β”œβ”€β”€ πŸ“„ tailwind.config.ts          # TailwindCSS configuration
β”œβ”€β”€ πŸ“„ tsconfig.json               # TypeScript configuration
└── πŸ“„ package.json                # Dependencies & scripts

πŸš€ Quick Start

Prerequisites

Make sure you have the following installed:

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

Installation

  1. Clone the repository

    git clone https://github.com/trhgatu/trhgatu-inf-nextjs-frontend-template.git
    cd trhgatu-inf-nextjs-frontend-template
  2. Install dependencies

    npm install
    # or
    yarn install
    # or
    pnpm install
  3. Set up environment variables

    cp .env.example .env.local
    # Edit .env.local with your configuration
  4. Run the development server

    npm run dev
    # or
    yarn dev
    # or
    pnpm dev
  5. Open your browser

    Navigate to http://localhost:3000 to see your application.


πŸ” Authentication Module

The template includes a complete authentication system:

  • Login Page: /login with form validation
  • Protected Routes: Automatic redirection for unauthenticated users
  • State Management: Redux-powered auth state
  • Type Safety: Full TypeScript support
  • Validation: Zod schema validation

Usage Example

import { useAuth } from '@/features/auth/hooks';

function ProtectedComponent() {
  const { user, isAuthenticated, login, logout } = useAuth();
  
  if (!isAuthenticated) {
    return <div>Please login to continue</div>;
  }
  
  return <div>Welcome, {user?.name}!</div>;
}

🎨 UI Components

Built with ShadCN/UI for maximum flexibility:

# Add new components
npx shadcn-ui@latest add button
npx shadcn-ui@latest add card
npx shadcn-ui@latest add form

Custom Components

The components/shared/ directory contains application-specific components:

  • Navbar: Responsive navigation with auth integration
  • Footer: Site footer with links and branding
  • Layout: Page layout wrapper

πŸ› οΈ Available Scripts

Command Description
npm run dev Start development server
npm run build Build for production
npm run start Start production server
npm run lint Run ESLint
npm run lint:fix Fix ESLint issues
npm run format Format code with Prettier
npm run type-check Run TypeScript compiler
npm run test Run tests

πŸ§ͺ CI/CD Pipeline

Automated workflow with GitHub Actions (.github/workflows/ci.yml):

βœ… Code Quality Checks
  β”œβ”€β”€ ESLint validation
  β”œβ”€β”€ Prettier formatting
  β”œβ”€β”€ TypeScript compilation
  └── Unit tests

βœ… Build & Deploy
  β”œβ”€β”€ Production build
  β”œβ”€β”€ Build artifact caching
  └── Deployment (when configured)

The pipeline runs on:

  • Push to main branch
  • Pull requests to main
  • Manual workflow dispatch

πŸ“¦ Key Dependencies

Core

  • next: ^14.0.0
  • react: ^18.0.0
  • typescript: ^5.0.0

Styling

  • tailwindcss: ^3.3.0
  • @tailwindcss/forms: ^0.5.0
  • class-variance-authority: ^0.7.0

State Management

  • @reduxjs/toolkit: ^1.9.0
  • react-redux: ^8.1.0

Validation & HTTP

  • zod: ^3.22.0
  • axios: ^1.5.0

Development

  • eslint: ^8.50.0
  • prettier: ^3.0.0
  • husky: ^8.0.0

🎯 Customization

Adding New Features

  1. Create a new feature directory under src/features/
  2. Add Redux slice in src/store/slices/
  3. Create API services in the feature directory
  4. Add routes to src/constants/routes.ts

Styling Customization

  1. Colors: Edit tailwind.config.ts
  2. Components: Modify ShadCN components in components/ui/
  3. Global Styles: Update src/app/globals.css

Environment Configuration

Create .env.local for local development:

NEXT_PUBLIC_API_URL=http://localhost:8000/api
NEXT_PUBLIC_APP_NAME=My App
DATABASE_URL=your_database_url

πŸš€ Deployment

Vercel (Recommended)

npm i -g vercel
vercel --prod

Docker

docker build -t my-nextjs-app .
docker run -p 3000:3000 my-nextjs-app

Other Platforms

  • Netlify: Connect your GitHub repository
  • Railway: One-click deployment
  • AWS/GCP: Use provided Dockerfiles

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License

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


πŸ’¬ Support


πŸ™ Acknowledgments

  • Next.js team for the amazing framework
  • Vercel for hosting and deployment platform
  • ShadCN for the beautiful UI components
  • TailwindCSS for the utility-first CSS framework

Built with ❀️ by Infinity (trhgatu)

"Code is how I reflect my soul."

⭐ Star this repo if you found it helpful!