Learn about database options and how to configure your database for the project
This guide covers the database creation, initialization, migration and connection to the database, and how to work with Drizzle ORM.
This guide mainly covers the creation and configuration of Postgres type databases, i.e. if you are using the main branch or the cloudflare branch, please refer to this guide.
Recommended to use hosted PostgreSQL database services, they provide easy setup and management, and often include free tiers sufficient for getting started.
Neon is a serverless PostgreSQL service with an excellent developer experience and is the default choice for this project. It's a great option for small projects and is free to get started.
Supabase provides PostgreSQL databases with additional features like authentication and storage. It's a great option for medium to large projects and is free to get started.
This project uses Drizzle ORM, a TypeScript ORM with a focus on type safety and developer experience. Drizzle is compatible with various database systems and providers.
Currently, the project is configured to use postgres-js driver for better compatibility with different databases and serverless environments:
src/db/index.ts
import { drizzle } from 'drizzle-orm/postgres-js';import postgres from 'postgres';import * as schema from './schema';let db: ReturnType<typeof drizzle>
If you are using a different database provider, you will need to update the src/lib/auth.ts file to use the correct driver and schema, and you can find more information in the Better Auth documentation.