Skip to content

akdevv/next-auth-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

50 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ Next Auth Starter

A production-ready Next.js authentication starter with modern features, comprehensive security, and excellent developer experience.

โœจ Features

๐Ÿ” Authentication & Security

  • Multiple Auth Methods: Email/password, Google OAuth, magic links
  • Two-Factor Authentication (2FA): TOTP with backup codes
  • Session Management: Secure sessions with device tracking
  • Email Verification: Automatic email verification flow
  • Password Security: bcrypt hashing with strength validation
  • Rate Limiting: Built-in protection against brute force attacks

๐Ÿ“ง Email System

  • Transactional Emails: Welcome, verification, password reset
  • React Email Templates: Beautiful, responsive email designs
  • Security Notifications: Login alerts and suspicious activity
  • Resend Integration: Reliable email delivery service

๐Ÿ›ก๏ธ Advanced Security

  • CSRF Protection: Built-in cross-site request forgery protection
  • Secure Headers: Comprehensive security headers configuration
  • Input Validation: Zod schemas for type-safe validation
  • Audit Logging: Complete authentication event tracking

๐Ÿ‘ค User Management

  • Profile Management: User profiles with avatar support
  • Device Management: View and revoke active sessions
  • Account Recovery: Multiple recovery options including backup codes
  • Account Deletion: GDPR-compliant data removal

๐ŸŽฏ Why This Project?

Building authentication from scratch is complex, time-consuming, and security-critical. This starter provides:

  • โœ… Production-ready authentication flows
  • โœ… Security best practices built-in
  • โœ… Modern tech stack with excellent DX
  • โœ… Comprehensive documentation and examples
  • โœ… Type-safe development experience
  • โœ… Scalable architecture for growth

๐Ÿ› ๏ธ Tech Stack

Core Framework

Authentication & Security

UI & Styling

Email & Communication

Development Tools

  • Bun - Fast JavaScript runtime & package manager
  • ESLint - Code linting and quality
  • Zod - TypeScript-first schema validation

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18+ or Bun
  • PostgreSQL database (we recommend Supabase)
  • Google Cloud Console account (for OAuth)
  • Resend account (for emails)

1. Clone & Install

git clone https://github.com/akdevv/next-auth-starter.git
cd next-auth-starter

# Install dependencies (recommended: use Bun)
bun install
# or npm install

2. Environment Setup

# Copy environment template
cp .env.example .env

# Fill in your environment variables
# See docs for detailed setup: /docs/getting-started/environment-variables

Required environment variables:

NEXT_PUBLIC_BASE_URL="http://localhost:3000"
AUTH_SECRET="your-secret-key"
DATABASE_URL="your-postgresql-url"
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"
NEXT_PUBLIC_RESEND_API_KEY="your-resend-api-key"

3. Database Setup

# Generate Prisma client
bun prisma generate

# Push schema to database
bun prisma db push

# (Optional) Seed database
bun prisma db seed

4. Start Development

bun dev

Visit http://localhost:3000 - your auth system is ready! ๐ŸŽ‰

๐Ÿ“– Documentation

Complete documentation is available at /docs when running the project:

๐Ÿ› ๏ธ Development

Available Scripts

# Development
bun dev              # Start development server with Turbopack
bun build            # Build for production
bun start            # Start production server
bun lint             # Run ESLint

# Database
bun prisma studio    # Open database browser
bun prisma migrate   # Run migrations
bun prisma generate  # Generate Prisma client
bun prisma reset     # Reset database

# Email Development
bun email            # Preview emails locally

Project Structure

next-auth-starter/
โ”œโ”€โ”€ app/                 # Next.js App Router
โ”‚   โ”œโ”€โ”€ api/            # API routes
โ”‚   โ”œโ”€โ”€ auth/           # Authentication pages
โ”‚   โ””โ”€โ”€ profile/        # User profile pages
โ”œโ”€โ”€ components/         # React components
โ”‚   โ”œโ”€โ”€ auth/          # Auth-specific components
โ”‚   โ”œโ”€โ”€ ui/            # shadcn/ui components
โ”‚   โ””โ”€โ”€ shared/        # Shared components
โ”œโ”€โ”€ content/           # Documentation (MDX)
โ”œโ”€โ”€ emails/            # Email templates
โ”œโ”€โ”€ lib/               # Utilities and configurations
โ”œโ”€โ”€ prisma/            # Database schema and migrations
โ”œโ”€โ”€ server/            # Server actions and utilities
โ””โ”€โ”€ schema/            # Zod validation schemas

๐Ÿ” Security Features

  • ๐Ÿ›ก๏ธ CSRF Protection - Built-in token validation
  • ๐Ÿ”’ Session Security - Secure cookie-based sessions
  • โšก Rate Limiting - Prevent brute force attacks
  • ๐Ÿ“ง Email Verification - Verify email ownership
  • ๐Ÿ” 2FA Support - TOTP with QR codes
  • ๐Ÿ”‘ Backup Codes - Emergency account recovery
  • ๐Ÿšจ Security Alerts - Login notifications
  • ๐Ÿ”„ Session Management - Multi-device session control

๐ŸŒŸ Production Ready

This starter includes production-ready features:

  • Performance Optimized - Server-side rendering, code splitting
  • SEO Friendly - Meta tags, structured data
  • Accessibility - WCAG compliant components
  • Mobile Responsive - Works on all devices
  • Error Handling - Graceful error boundaries
  • Monitoring Ready - Built-in logging and analytics hooks

๐Ÿš€ Deployment

Deploy to your favorite platform:

Vercel (Recommended)

vercel deploy

Docker

docker build -t next-auth-starter .
docker run -p 3000:3000 next-auth-starter

Other Platforms

  • Netlify - Static export support
  • Railway - Database included
  • AWS/GCP/Azure - Serverless functions

๐Ÿค Contributing

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

Development Setup

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

๐Ÿ“„ License

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

๐Ÿ™ Acknowledgments

๐Ÿ“ž Support

  • ๐Ÿ“– Documentation: Visit /docs in your running project
  • ๐Ÿ’ฌ Issues: GitHub Issues
  • ๐Ÿ› Bug Reports: Use issue templates
  • ๐Ÿ’ก Feature Requests: Open a discussion

Built with โค๏ธ by the community. Star โญ if this project helped you!

About

Next.js Authentication Starter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

โšก