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
ποΈ Architecture
|
π¨ UI/Styling
|
β‘ State Management
|
π οΈ Developer Experience
|
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 |
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
Make sure you have the following installed:
- Node.js 18+
- npm, yarn, or pnpm
-
Clone the repository
git clone https://github.com/trhgatu/trhgatu-inf-nextjs-frontend-template.git cd trhgatu-inf-nextjs-frontend-template
-
Install dependencies
npm install # or yarn install # or pnpm install
-
Set up environment variables
cp .env.example .env.local # Edit .env.local with your configuration
-
Run the development server
npm run dev # or yarn dev # or pnpm dev
-
Open your browser
Navigate to http://localhost:3000 to see your application.
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
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>;
}
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
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
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 |
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
- next: ^14.0.0
- react: ^18.0.0
- typescript: ^5.0.0
- tailwindcss: ^3.3.0
- @tailwindcss/forms: ^0.5.0
- class-variance-authority: ^0.7.0
- @reduxjs/toolkit: ^1.9.0
- react-redux: ^8.1.0
- zod: ^3.22.0
- axios: ^1.5.0
- eslint: ^8.50.0
- prettier: ^3.0.0
- husky: ^8.0.0
- Create a new feature directory under
src/features/
- Add Redux slice in
src/store/slices/
- Create API services in the feature directory
- Add routes to
src/constants/routes.ts
- Colors: Edit
tailwind.config.ts
- Components: Modify ShadCN components in
components/ui/
- Global Styles: Update
src/app/globals.css
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
npm i -g vercel
vercel --prod
docker build -t my-nextjs-app .
docker run -p 3000:3000 my-nextjs-app
- Netlify: Connect your GitHub repository
- Railway: One-click deployment
- AWS/GCP: Use provided Dockerfiles
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- π§ Email: trananhtu1112003@gmail.com
- π Issues: GitHub Issues
- π¬ Discussions: GitHub Discussions
- 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!