A modern, production-ready Next.js 15 template with Auth.js (NextAuth.js v5), Prisma ORM, PostgreSQL, and Shadcn UI. Perfect for building secure, scalable web applications with OAuth authentication.
- π OAuth Authentication - Google, GitHub, and Discord providers
- π¨ Modern UI - Shadcn UI components with Tailwind CSS v4
- ποΈ Database - Prisma ORM with PostgreSQL (Neon)
- π Account Linking - Automatic linking of multiple OAuth providers
- π Dark Mode - Built-in theme switching
- π± Responsive Design - Mobile-first approach
- β‘ Performance - Next.js 15 with Turbopack
- π‘οΈ Type Safety - Full TypeScript support
- π Production Ready - Optimized for Vercel deployment
This template is built with performance in mind, achieving excellent Lighthouse scores:
| Category | Score |
|---|---|
| Performance | 100/100 |
| Accessibility | 100/100 |
| Best Practices | 100/100 |
| SEO | 100/100 |
βββ app/ # Next.js 15 App Router
β βββ (auth)/ # Authentication routes
β βββ (dashboard)/ # Protected dashboard routes
β βββ (marketing)/ # Public marketing pages
βββ components/ # Reusable UI components
β βββ ui/ # Shadcn UI components
β βββ providers/ # Context providers
βββ lib/ # Utility functions
βββ prisma/ # Database schema and migrations
βββ types/ # TypeScript type definitions
- Node.js 18+
- PostgreSQL database (Neon recommended)
- OAuth app credentials for Google, GitHub, and/or Discord
git clone https://github.com/YTDev/Next-Auth-Starter.git
cd next-auth-starter
npm installCreate a .env.local file in the root directory:
# Database
DATABASE_URL="postgresql://username:password@host:port/database"
# Auth.js
AUTH_SECRET="your-super-secret-key-here"
AUTH_URL="http://localhost:3000"
# OAuth Providers
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"
GITHUB_CLIENT_ID="your-github-client-id"
GITHUB_CLIENT_SECRET="your-github-client-secret"
DISCORD_CLIENT_ID="your-discord-client-id"
DISCORD_CLIENT_SECRET="your-discord-client-secret"
# Site Configuration
NEXT_PUBLIC_SITE_URL="http://localhost:3000"# Generate Prisma client
npx prisma generate
# Run database migrations
npx prisma db push
# (Optional) Open Prisma Studio
npx prisma studionpm run devVisit http://localhost:3000 to see your app!
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable Google+ API
- Create OAuth 2.0 credentials
- Add authorized redirect URI:
http://localhost:3000/api/auth/callback/google
- Go to GitHub Developer Settings
- Create a new OAuth App
- Set Authorization callback URL:
http://localhost:3000/api/auth/callback/github
- Go to Discord Developer Portal
- Create a new application
- Add OAuth2 redirect:
http://localhost:3000/api/auth/callback/discord
app/api/auth/[...nextauth]/route.ts- Auth.js configurationprisma/schema.prisma- Database schemacomponents/auth-card.tsx- Authentication UI componentapp/(dashboard)/dashboard/page.tsx- Protected dashboardmiddleware.ts- Route protection middleware
- Install the provider package (if needed)
- Add provider configuration in
app/api/auth/[...nextauth]/route.ts - Add environment variables
- Update the UI components
The template uses Tailwind CSS v4 with Shadcn UI components. Customize by:
- Modifying
tailwind.config.ts - Updating component variants in
components/ui/ - Adding custom CSS in
app/globals.css
# After modifying schema.prisma
npx prisma generate
npx prisma db push- Push your code to GitHub
- Connect your repository to Vercel
- Set environment variables in Vercel dashboard
- Deploy!
# Update AUTH_URL to your production domain
AUTH_URL="https://your-domain.vercel.app"
# Update OAuth redirect URIs
# Google: https://your-domain.vercel.app/api/auth/callback/google
# GitHub: https://your-domain.vercel.app/api/auth/callback/github
# Discord: https://your-domain.vercel.app/api/auth/callback/discord# For production database
npx prisma db push- CSRF Protection - Built into Auth.js
- Session Management - Secure session handling
- Account Linking - Automatic linking of multiple providers
- Environment Variables - Secure credential management
- Type Safety - Prevents runtime errors
npm run dev # Start development server with Turbopack
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLint- Next.js Documentation
- Auth.js Documentation
- Prisma Documentation
- Shadcn UI Documentation
- Tailwind CSS Documentation
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Built with β€οΈ by YTDev
