A comprehensive Next.js template with routing, API routes, loading states, and error boundaries.
- Features
- Getting Started
- Project Structure
- Component Libraries
- API Endpoints
- SEO Setup
- Learn More
- Deploy
- App Router - File-based routing with layouts and nested routes
- API Routes - RESTful API endpoints (
/api/health,/api/data) - Loading States - Automatic loading UI with
loading.tsxfiles - Error Boundaries - Graceful error handling with
error.tsxfiles - TypeScript - Full type safety with TypeScript
- Tailwind CSS - Utility-first CSS framework
- Component Libraries - Optional setup for Hero UI, shadcn/ui, or Chakra UI
- Custom 404 Page - Branded not-found page
- Setup Script - Interactive CLI to customize your project
The interactive setup script will configure everything for you:
npm run setup "My Project Name"Or run it interactively (it will prompt for the project name):
npm run setupWhat the setup script does:
- ✅ Updates all template references with your project name
- ✅ Cleans and installs all dependencies (
npm ci) - ✅ Presents an interactive menu to choose a component library
- ✅ Automatically installs and configures your selected library:
- Hero UI: Installs packages, adds provider to layout.tsx, updates tailwind.config.ts
- shadcn/ui: Initializes shadcn, installs 6 common components (button, card, input, label, dialog, dropdown-menu)
- Chakra UI: Installs packages and adds ChakraProvider to layout.tsx
- None: Skip component library installation
- ✅ Components are ready to use immediately after setup!
After setup completes, start the development server:
npm run devOpen http://localhost:3000 with your browser to see the result.
src/app/
├── layout.tsx # Root layout
├── page.tsx # Home page
├── loading.tsx # Root loading UI
├── error.tsx # Root error boundary
├── not-found.tsx # 404 page
├── about/
│ ├── page.tsx # About page
│ ├── loading.tsx # About loading UI
│ └── error.tsx # About error boundary
├── dashboard/
│ ├── layout.tsx # Dashboard layout with sidebar
│ ├── page.tsx # Dashboard page
│ ├── loading.tsx # Dashboard loading UI
│ └── settings/
│ └── page.tsx # Nested route
└── api/
├── health/
│ └── route.ts # Health check endpoint
└── data/
└── route.ts # CRUD data endpoint
The setup script provides fully automated installation and configuration for popular component libraries:
React components built on top of Tailwind CSS with beautiful design and accessibility.
Automatic Setup:
- ✅ Installs
@heroui/reactandframer-motion - ✅ Adds
HeroUIProvidertolayout.tsx - ✅ Updates
tailwind.config.tswith Hero UI plugin
Usage after setup:
import { Button, Card, Input } from '@heroui/react';
<Button color="primary">Click me</Button>Documentation: https://www.heroui.com
Beautifully designed components built with Radix UI and Tailwind CSS.
Automatic Setup:
- ✅ Initializes shadcn/ui with default configuration
- ✅ Auto-installs 6 common components:
button,card,input,label,dialog,dropdown-menu
- ✅ Creates
components/uidirectory structure
Usage after setup:
import { Button } from "@/components/ui/button";
import { Card } from "@/components/ui/card";
<Button variant="default">Click me</Button>Add more components:
npx shadcn@latest add [component-name]Documentation: https://ui.shadcn.com
Simple, modular and accessible component library for React applications.
Automatic Setup:
- ✅ Installs
@chakra-ui/react,@emotion/react,@emotion/styled, andframer-motion - ✅ Adds
ChakraProvidertolayout.tsx - ✅ Configures "use client" directive
Usage after setup:
import { Button, Box, Card, Input } from '@chakra-ui/react';
<Button colorScheme="blue">Click me</Button>Documentation: https://chakra-ui.com
Skip component library installation and use your own preferred solution or add one manually later.
GET /api/healthGET /api/data # Get all items
GET /api/data?id=1 # Get item by ID
POST /api/data # Create new item
PUT /api/data # Update item
DELETE /api/data?id=1 # Delete itemTo learn more about Next.js, check out:
This template includes a comprehensive SEO setup script that can be run standalone:
npm run seo-setupFor faster setup or CI/CD automation, you can use a template file:
-
Copy the template:
cp seo-template.json my-seo-config.json
-
Edit the configuration in
my-seo-config.json:{ "siteName": "My Awesome Site", "siteTagline": "Building amazing things", "siteUrl": "https://example.com", "author": "Your Name", "locale": "en", "businessType": "saas", "keywords": ["nextjs", "react", "typescript"], "social": { "twitter": "yourusername", "facebook": "https://facebook.com/yourpage", "linkedin": "https://linkedin.com/in/yourprofile" } } -
Run setup with the template:
npm run seo-setup -- --template=my-seo-config.json
The script also supports interactive mode where it will prompt you for all information:
npm run seo-setupYou can also choose to use a template file during the interactive session.
The SEO setup creates:
src/lib/seo.config.ts- Centralized SEO configurationsrc/lib/metadata-helper.ts- Helper functions for page metadatasrc/lib/structured-data.tsx- JSON-LD schema helperssrc/app/sitemap.ts- Automatic sitemap generationsrc/app/robots.ts- SEO-friendly robots.txtsrc/app/manifest.ts- PWA manifestdocs/SEO_GUIDE.md- Complete SEO guide
Deploy your Next.js app using Vercel or any Node.js hosting platform.
Check out the Next.js deployment documentation for more details.