A modern authentication-ready SvelteKit project using Better Auth, Drizzle ORM, and Tailwind CSS.
# Clone the repository
git clone https://github.com/Jpisnice/SvelteKit-BetterAuth-Starter.git
cd SvelteKit-BetterAuth-Starter
# Install dependencies using Bun
bun install
# Or using npm
npm install
Create a .env file based on the provided .env.example:
# Copy example environment variables
cp .env.example .env
Update the following values in your .env file:
BETTER_AUTH_SECRET: Generate a strong random stringGITHUB_CLIENT_ID & GITHUB_CLIENT_SECRET: From GitHub OAuth AppsGOOGLE_CLIENT_ID & GOOGLE_CLIENT_SECRET: From Google Cloud Console# Start the PostgreSQL database using Docker
bun db:start # or: npm run db:start
# Push the schema to the database
bun db:push # or: npm run db:push
# Start the development server with Bun
bun dev
# Or start with the browser opening automatically
bun dev -- --open
# Using npm instead
# npm run dev
# npm run dev -- --open
# Start the database
bun db:start # or: npm run db:start
# View database with Drizzle Studio
bun db:studio # or: npm run db:studio
# Apply migrations
bun db:migrate # or: npm run db:migrate
# Run unit tests
bun test:unit # or: npm run test:unit
# Run e2e tests
bun test:e2e # or: npm run test:e2e
# Run all tests
bun test # or: npm test
# Build for production
bun run build # or: npm run build
# Preview the production build locally
bun preview # or: npm run preview
This project uses Better Auth with GitHub and Google OAuth providers. Users can sign in via:
/login - Sign in page with social providershttp://localhost:5173 (for development)http://localhost:5173/api/auth/callback/github.env file as GITHUB_CLIENT_ID and GITHUB_CLIENT_SECREThttp://localhost:5173/api/auth/callback/google (for development).env file as GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRETFor production deployment, make sure to update the callback URLs to your production domain.
The project is configured with Tailwind CSS and includes the following plugins:
@tailwindcss/forms - Better form styling@tailwindcss/typography - Rich text content stylingThe database schema is defined in src/lib/server/db/schema.ts. After making changes to the schema, run:
bun db:push # or: npm run db:push
.env file secure and not commit it to version controlTo deploy your app, you may need to install an adapter for your target environment.