Skip to content

fogboots/nextjs-template

Repository files navigation

Next.js Template

A production-ready Next.js template with authentication, database, and all the essentials pre-configured.

Stack

Layer Tech
Framework Next.js 16 (App Router)
Language TypeScript
Styling Tailwind CSS v4
UI Components shadcn/ui
Icons Lucide React
Auth NextAuth.js (credentials + OAuth)
Database Convex
Forms React Hook Form + Zod
Email Resend
Toasts Sonner
Linting ESLint
Formatting Prettier
Git Hooks Husky + lint-staged

Quick Start

Option 1: Use as GitHub Template

  1. Click "Use this template" on GitHub
  2. Clone your new repo
  3. Run setup:
npm run setup

Option 2: Clone directly

git clone https://github.com/yourusername/nextjs-template.git my-app
cd my-app
npm run setup

Manual Setup

If you prefer manual setup:

# Install dependencies
npm install

# Copy environment variables
cp .env.example .env.local

# Generate NextAuth secret
openssl rand -base64 32
# Add output to NEXTAUTH_SECRET in .env.local

# Initialize Convex
npx convex dev
# Copy the URL to NEXT_PUBLIC_CONVEX_URL in .env.local

# Setup Husky
npx husky init
echo "npx lint-staged" > .husky/pre-commit

Development

# Run both Convex and Next.js
npm run dev

# Or run separately
npm run dev:convex  # Terminal 1
npm run dev:next    # Terminal 2

Open http://localhost:3000

Environment Variables

Copy .env.example to .env.local and fill in:

Variable Required Description
NEXT_PUBLIC_CONVEX_URL Yes Convex deployment URL
NEXTAUTH_SECRET Yes Random string for session encryption
NEXTAUTH_URL Yes Your app URL (http://localhost:3000 for dev)
GITHUB_ID No GitHub OAuth client ID
GITHUB_SECRET No GitHub OAuth client secret
RESEND_API_KEY No Resend API key for emails
EMAIL_FROM No Email sender address

Project Structure

├── convex/                 # Convex backend
│   ├── schema.ts          # Database schema
│   └── users.ts           # User queries/mutations
├── src/
│   ├── app/
│   │   ├── (auth)/        # Auth pages (login, register)
│   │   ├── (dashboard)/   # Protected pages
│   │   ├── api/           # API routes
│   │   └── ...
│   ├── components/
│   │   ├── ui/            # shadcn components
│   │   ├── layout/        # Header, Sidebar, etc.
│   │   └── features/      # Feature components
│   ├── hooks/             # Custom React hooks
│   ├── lib/               # Utilities
│   └── types/             # TypeScript types
├── scripts/
│   └── setup.mjs          # Setup wizard
└── ...

Scripts

Command Description
npm run dev Run Convex + Next.js
npm run dev:next Run Next.js only
npm run dev:convex Run Convex only
npm run build Build for production
npm run lint Run ESLint
npm run format Format with Prettier
npm run typecheck Run TypeScript checks
npm run setup Run setup wizard

Features

Authentication

  • Email/password authentication
  • GitHub OAuth (optional)
  • Protected routes via proxy.ts
  • Session management with NextAuth.js

Database

  • Convex for real-time data
  • Type-safe queries and mutations
  • Automatic TypeScript generation

UI

  • shadcn/ui components pre-installed
  • Dark mode support
  • Responsive sidebar layout
  • Toast notifications

Adding OAuth Providers

GitHub

  1. Go to GitHub Developer Settings
  2. Create a new OAuth App
  3. Set callback URL to http://localhost:3000/api/auth/callback/github
  4. Add GITHUB_ID and GITHUB_SECRET to .env.local

Google

  1. Go to Google Cloud Console
  2. Create OAuth 2.0 credentials
  3. Add authorized redirect URI: http://localhost:3000/api/auth/callback/google
  4. Add provider to src/app/api/auth/[...nextauth]/route.ts

Deployment

Vercel

  1. Push to GitHub
  2. Import to Vercel
  3. Add environment variables
  4. Deploy

Convex

npx convex deploy

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published