Database

Overview

Get started with the database.

We're using Drizzle ORM to interact with the database. It basically adds a little layer of abstraction between our code and the database.

If you know SQL, you know Drizzle.

For the database we're leveraging PostgreSQL (which comes directly from Supabase), but you could use any other database that Drizzle ORM supports (basically any SQL database e.g. MySQL, SQLite, etc.).

Why Drizzle ORM?

Drizzle ORM is a powerful tool that allows you to interact with the database in a type-safe manner. It ships with 0 (!) dependencies and is designed to be fast and easy to use.

Setup

To start interacting with the database you first need to ensure that your database instance is up and running.

For local development we recommend using the Supabase Local container.

You can start the container with the following command:

pnpm db:setup

This will start the database container and initialize the database with the latest schema.

Where is DATABASE_URL?

DATABASE_URL is a connection string that is used to connect to the database. When the command will finish it will be displayed in the console.

Then, you need to set DATABASE_URL environment variable in root .env.local file.

.env.local
# The database URL is used to connect to your database.
DATABASE_URL="postgresql://postgres:postgres@127.0.0.1:54322/postgres"

You're ready to go! 🥳

Studio

TurboStarter provides you also with an interactive UI where you can explore your database and test queries called Studio.

To run the Studio, you can use the following command:

pnpm db:studio

This will start the Studio on https://local.drizzle.studio.

Drizzle Studio

Next steps

Last updated on

On this page

Ship your startup everywhere. In minutes.Get TurboStarter