A complete authentication solution using Better Auth, Next.js, and Prisma.
- 🔐 Complete authentication system
- 📧 Email/Password authentication
- 🔑 Social authentication (Google, GitHub, etc.)
- 🎯 Type-safe with TypeScript
- 🚀 Server Actions support
- 📱 Responsive design
- 🔄 Session management
- 🛡️ CSRF protection
- Node.js 18+
- pnpm (recommended) or npm
- PostgreSQL database
- Clone the project
git clone https://github.com/Kinfe123/better-auth-nextjs
cd better-auth-nextjs- Install dependencies
pnpm install- Setup Env variables
cp .env.example .envEdit .env with your configuration:
DATABASE_URL="postgresql://user:password@localhost:5432/mydb?schema=public"
AUTH_SECRET="your-auth-secret" # Generate with: openssl rand -base64 32
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"
TWITTER_CLIENT_ID="your-twitter-client-id"
TWITTER_CLIENT_SECRET="your-twitter-client-secret"
GITHUB_CLIENT_ID="your-github-client-id"
GITHUB_CLIENT_SECRET="your-github-client-secret"- Run database migrations
pnpm prisma generate
pnpm prisma db push- Run dev server
pnpm devCommon issues and solutions:
-
Database Connection Issues
- Verify your DATABASE_URL in .env
- Ensure PostgreSQL is running
- Check database permissions
-
Authentication Errors
- Verify AUTH_SECRET is set
- Check social provider credentials
- Ensure proper CORS configuration
-
Session Issues
- Check cookie settings
- Verify nextCookies plugin is enabled
- Ensure proper redirect handling
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License.