A modern, production-ready starter template for building authenticated web applications with Nuxt 4 and Better-Auth. This template provides a complete authentication system with TypeScript, PostgreSQL, and a beautiful UI powered by Nuxt UI Pro.
- π Better-Auth Integration - Modern authentication library with session management
- π€ Complete Auth Flow - Registration, login, logout, and session persistence
- π Password Reset - Built-in password reset functionality (
β οΈ currently logs to console - see configuration) - π‘οΈ Role-Based Access Control - Admin roles and permissions
- π Secure Sessions - HTTP-only cookies with 7-day persistence
- π« User Management - Ban/suspension system built-in
- β‘ Nuxt 4 - Latest version with full TypeScript support
- π¨ Nuxt UI Pro - Premium UI components library
- ποΈ Drizzle ORM - Type-safe database queries
- π PostgreSQL - Robust database with Docker support
- π¦ Pinia - State management with auth store
- π― TypeScript - Full type safety across the stack
- π³ Docker Compose - One-command database setup
- π§ Drizzle Studio - Visual database management
- π ESLint & TypeScript - Code quality tools pre-configured
- π Multiple Layouts - Separate auth and app layouts
- π Dark Mode - Built-in color mode support
- Node.js 18+ and pnpm
- Docker and Docker Compose (for PostgreSQL)
- PostgreSQL (if not using Docker)
-
Clone the repository
git clone <your-repo-url> cd mrx-nuxt
-
Install dependencies
pnpm install
-
Set up environment variables
cp .env.example .env
Update the
.envfile with your configuration:NUXT_SITE_NAME="Your App Name" NUXT_SITE_ENV="development" NUXT_SITE_URL="http://localhost:3000" NUXT_DATABASE_URL="postgresql://user:password@localhost:5432/dbname" NUXT_AUTH_SECRET="your-secret-key" NUXT_SESSION_SECRET="your-session-secret" NUXT_ADMIN_EMAIL="admin@example.com" NUXT_ADMIN_PASSWORD="optional-secure-password" # Optional - random password generated if not set
-
Start the database
pnpm docker:up
-
Push the database schema
pnpm db:push
-
Start the development server
pnpm dev
Visit
http://localhost:3000to see your app running!
mrx-nuxt/
βββ app/ # Frontend application
β βββ assets/ # CSS and static assets
β βββ composables/ # Vue composables
β β βββ useAuthClient.ts # Auth client composable
β βββ layouts/ # App layouts
β β βββ auth.vue # Auth pages layout
β β βββ default.vue # Main app layout
β βββ middleware/ # Route middleware
β β βββ is-authenticated.global.ts
β β βββ is-admin.ts
β βββ pages/ # Application pages
β β βββ auth/ # Auth pages (login, register)
β β βββ admin.vue # Admin dashboard
β β βββ index.vue # Home page
β βββ plugins/ # Nuxt plugins
β βββ stores/ # Pinia stores
β βββ auth.store.ts # Auth state management
βββ server/ # Backend API
β βββ api/ # API routes
β βββ config/ # Server configuration
β βββ database/ # Database schema
β β βββ schema.ts # Drizzle schema definition
β βββ guards/ # Auth guards
β βββ middleware/ # Server middleware
β βββ utils/ # Server utilities
β βββ auth.ts # Better-Auth configuration
βββ shared/ # Shared types and utilities
# Start PostgreSQL with Docker
pnpm docker:up
# Stop PostgreSQL
pnpm docker:down
# Push schema changes
pnpm db:push
# Open Drizzle Studio (database GUI)
pnpm db:studioThis template uses Nuxt UI Pro for premium components. Key features:
- Beautiful, accessible components
- Dark mode support out of the box
- Responsive design
- Form components with validation
- Toast notifications
- Modal dialogs
- And much more!
This project is pre-configured for Claude AI agent development with the following features:
.claudedirectory - Contains Claude-specific configuration and memory files.mcp.json- Model Context Protocol configuration for enhanced AI interactions./agent/**- Dedicated directory for AI agent-related code and utilities
Feel free to utilize these resources for building AI-powered features:
- Claude memory management and context persistence
- Custom agent workflows and integrations
- MCP tool configurations for extended capabilities
These files are optional and can be removed if you're not using Claude AI features.
Ensure all required environment variables are set in production:
NUXT_SITE_NAME="Your Production App"
NUXT_SITE_ENV="production"
NUXT_SITE_URL="https://yourdomain.com"
NUXT_DATABASE_URL="your-production-db-url"
NUXT_AUTH_SECRET="strong-random-secret"
NUXT_SESSION_SECRET="another-strong-secret"# Build the application
pnpm build
# Preview production build
pnpm previewpnpm dev # Start development server
pnpm build # Build for production
pnpm preview # Preview production build
pnpm typecheck # Run TypeScript type checking
pnpm lint # Run ESLint
pnpm lint:fix # Fix ESLint issues
pnpm db:push # Push database schema
pnpm db:studio # Open Drizzle Studio
pnpm docker:up # Start PostgreSQL container
pnpm docker:down # Stop PostgreSQL container
# Development utilities
pnpm exec -- tsx scripts/fake-seeder.ts # Generate 100 fake users for testingThe nuxt.config.ts file is pre-configured with:
- TypeScript support
- Nuxt UI Pro
- SEO module
- Authentication setup
- Database integration
Authentication is configured in /server/utils/auth.ts with:
- Email/password authentication
- Admin plugin for roles
- Drizzle adapter
- Session management
- ULID for unique IDs
- Password reset functionality
/server/utils/auth.ts currently logs reset links to the console (lines 16-17). This is intended for development only. For production, you must:
-
Replace the
sendResetPasswordfunction to send actual emails:sendResetPassword: async ({ url, user }) => { // TODO: Implement email sending // Example: await sendEmail(user.email, 'Password Reset', url) }
-
Configure an email service (SendGrid, Postmark, AWS SES, etc.)
-
Remove the console.log statements to prevent security risks
First registered user is automatically set as admin. Check better-auth hook on /server/utils/auth.ts for details.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.
- Nuxt - The Intuitive Vue Framework
- Better-Auth - Modern Authentication for Full-Stack Apps
- Drizzle ORM - TypeScript ORM
- Nuxt UI Pro - Premium Vue Components
Built with β€οΈ using Nuxt 4 and Better-Auth