Next-start
database

Overview

Get started with database

This starter template uses Drizzle as the database. Drizzle is a lightweight, open-source database that provides a simple and efficient way to store and manage data. It's designed to be easy to use and integrate with your Next.js application.

Why Drizzle ORM?

Drizzle ORM is lightweight, type-safe, and ships with zero dependencies. It offers a SQL-first approach with seamless migrations, making database interactions simple and efficient.

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

Setup

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

Local development

  1. Install Docker
  2. Run docker compose up -d in the root of the project. This will start a local PostgreSQL instance.
  3. Ensure the environment variables in your .env file are configured to point to your local database. The connection string is as following:
    # The database URL is used to connect to your database.
    DATABASE_URL="postgresql://postgres:postgres@localhost:3000/postgres"

Studio

Drizzle ORM also provides you with an interactive UI where you can explore your database and test queres callded Studio

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

pnpx drizzle-kit studio

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

Drizzle Studio

How is this guide?

On this page