A modern authentication starter template built with SvelteKit and Better Auth, featuring a beautiful UI powered by Tailwind CSS and shadcn-svelte components.
- 🔐 Secure authentication with Better Auth
- Email/Password authentication
- Google OAuth integration
- Session management
- Protected routes
- 🎨 Modern UI with shadcn-svelte components
- 🎯 Type-safe database with Drizzle ORM
- 🚀 Fast development with Bun
- 📱 Responsive design with Tailwind CSS
- ✨ Code quality tools:
- TypeScript for type safety
- ESLint for code linting
- Prettier for code formatting
- Bun (v1.0.0 or higher)
- PostgreSQL database
- Google OAuth credentials (for social login)
-
Clone the repository:
git clone https://github.com/yourusername/sveltekit-better-auth-starter.git cd sveltekit-better-auth-starter -
Install dependencies:
bun install
-
Create a
.envfile in the root directory:DATABASE_URL=postgresql://user:password@localhost:5432/your_database GOOGLE_CLIENT_ID=your_google_client_id GOOGLE_CLIENT_SECRET=your_google_client_secret
-
Push the database schema:
bun run db:push
-
Start the development server:
bun run dev
Visit http://localhost:5173 to see your application running.
sveltekit-better-auth-starter/
├── src/
│ ├── lib/
│ │ ├── components/ # UI components
│ │ ├── database/ # Database schema and configuration
│ │ ├── server/ # Server-side authentication logic
│ │ └── hooks/ # Custom SvelteKit hooks
│ └── routes/ # SvelteKit routes
├── static/ # Static assets
└── [Configuration files]- Users can sign up using email/password or Google OAuth
- On successful authentication, a session is created
- Protected routes (e.g.,
/dash) require valid session - Users can sign out to invalidate their session
The project uses Drizzle ORM with PostgreSQL and includes the following tables:
users: User informationsessions: Active sessionsaccounts: OAuth accountsverifications: Email verification tokens
bun run dev- Start development serverbun run build- Build for productionbun run preview- Preview production buildbun run lint- Run ESLintbun run format- Format code with Prettierbun run db:push- Push database schema changesbun run db:studio- Open Drizzle Studio
This project is configured for deployment on Vercel using the SvelteKit adapter. Make sure to:
- Set up your environment variables in your deployment platform
- Configure your PostgreSQL database
- Deploy your application
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.