Overview
Learn how to use the database in supastarter.
supastarter includes a pre-configured database layer that supports both Prisma and Drizzle as your ORM (Object-Relational Mapping). PostgreSQL is the default database, but you can also use MySQL or SQLite. supastarter works with any PostgreSQL-compatible provider like Neon, Supabase, PlanetScale (MySQL), Turso (libSQL), or Railway.
You can find the schema and configuration in the packages/database directory either in the prisma or drizzle folder.
Database provider guides
Follow a provider-specific guide for detailed setup instructions:
Neon Postgres
Serverless Postgres with connection pooling and branching.
Supabase Postgres
Managed Postgres with storage and real-time features.
PlanetScale
MySQL-compatible serverless database with branching.
Turso (libSQL)
Edge-hosted SQLite with embedded replicas.
Railway Postgres
Simple, affordable managed Postgres.
Configure the ORM
Prisma
You can skip this if you are using Prisma with PostgreSQL, as this is the default setup.
If you are using a different database than PostgreSQL, you will need to configure the database provider in the /packages/database/prisma/schema.prisma file.
datasource db {
provider = "mysql" // or "mongodb"
}You will also need to change the database provider in the /packages/auth/auth.ts file:
export const auth = betterAuth({
database: prismaAdapter(db, {
provider: "mysql", // or "mongodb"
}),
});In case you are using MySQL, you will also need to remove all occurrences of mode: "insensitive" from the project. This is a feature that Prisma does not support for MySQL, so it will cause errors on build.
Simply search in the project for mode: "insensitive" and remove it.
Drizzle
If you want to use Drizzle instead of Prisma, you will need to change the export in the /packages/database/index.ts file:
export * from "./drizzle";Next make sure to use the drizzle adapter in the /packages/auth/auth.ts file:
export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "mysql", // or "sqlite" or "pg"
}),
});If you are using a different database than PostgreSQL, you will need to export the schema for either mysql or sqlite from the /packages/database/drizzle/schemaindex].ts file.
export * from "./postgres";
// or export * from "./mysql";
// or export * from "./sqlite";Lastly, you will need to set up the correct database client in the client.ts file. Follow the instructions in the Drizzle documentation for the database provider you are using. For PostgreSQL you can use the following example:
import { drizzle } from "drizzle-orm/node-postgres";
import * as schema from "./schema/postgres";
const databaseUrl = process.env.DATABASE_URL as string;
if (!databaseUrl) {
throw new Error("DATABASE_URL is not set");
}
export const db = drizzle(databaseUrl, {
schema,
});Frequently asked questions
Which database should I use with supastarter?
PostgreSQL is the recommended and default database for supastarter. It works out of the box with both Prisma and Drizzle and is supported by all major database providers like Neon, Supabase, and Railway. If you need MySQL, supastarter supports it as well through both ORMs.
How do I switch between Prisma and Drizzle?
supastarter supports both Prisma and Drizzle ORMs. You can switch between them by changing the export in /packages/database/index.ts and updating the auth adapter in /packages/auth/auth.ts. See the database overview for detailed instructions.
Can I use MySQL or SQLite instead of PostgreSQL?
Yes. supastarter supports MySQL and SQLite in addition to PostgreSQL. You will need to update the database provider configuration in your ORM schema and auth adapter. Note that some features like case-insensitive search (mode: "insensitive" in Prisma) are not available with MySQL.
Which database provider should I choose?
You are free to choose whatever database provider you want as long as it is compatible with Prisma or Drizzle. The provider guides in this documentation cover some popular options, but they are not the only choices. That said, here are some recommendations: Neon is great for serverless deployments with connection pooling and branching. Supabase offers a full Postgres platform with storage and real-time features. Railway is simple and affordable for getting started. PlanetScale is ideal if you prefer MySQL with branching. See the database provider guides for setup instructions for each provider.