Complete Setup Example
A complete, production-ready authentication setup with all features enabled.
What You'll Build
ā
Login & Registration
Complete auth flow with email verification
š„
Organizations
Multi-tenant with organization switching
š”ļø
Security
Account lockout, 2FA, restrictions
āļø
Admin Dashboard
Manage users and security settings
Step 1: Initial Setup
Step 2: Configure Environment
Create a .env
file:
Step 3: Set Up NextAuth API Route
Step 4: Create Login Page
Step 5: Create Dashboard
Step 6: Add Middleware Protection
Step 7: Create Admin Panel
Final Project Structure
my-auth-app/ āāā app/ ā āāā api/ ā ā āāā auth/ ā ā āāā [...nextauth]/ ā ā āāā route.ts ā āāā login/ ā ā āāā page.tsx ā āāā dashboard/ ā ā āāā page.tsx ā āāā admin/ ā ā āāā security/ ā ā āāā page.tsx ā āāā layout.tsx ā āāā page.tsx āāā prisma/ ā āāā schema.prisma ā āāā seed.ts āāā middleware.ts āāā .env āāā package.json āāā next.config.js
Running the Application
1. Start Development Server
npm run dev
2. Visit Login Page
Navigate to http://localhost:3000/login
3. Use Demo Credentials
- Email:
owner@example.com
- Password:
password123
4. Access Admin Panel
Navigate to http://localhost:3000/admin/security
Next Steps
Download Complete Example
Get the full source code with all features configured