Skip to main content
If you want PostgreSQL in Next.js without a heavier ORM layer, Drizzle is the clean middle path: typed schema, typed queries, and SQL that still feels close to the database. This quickstart keeps to the shortest useful path: one DBHost database, one Drizzle setup, and one server-side query. Best fit: Teams that want type-safe SQL, explicit schema files, and a lighter abstraction than Prisma. Not for: Teams that want full ORM modeling, or teams that want zero schema tooling and prefer plain SQL only. If you want to compare this path with Prisma or plain pg, start with the Next.js + PostgreSQL guide.

What you need

  • A DBHost account and one active database
  • A Next.js app
  • Node.js 18 or later
  • Drizzle ORM, pg, and Drizzle Kit installed in the app
DBHost exposes PostgreSQL through PgBouncer on port 6432. That pooled connection string is the default path for normal Drizzle app queries.

1. Create a database in DBHost

Create a database from the dashboard, then copy the connection string from the database detail page. If you are starting from zero, that is still the fastest first step. DBHost gives you the host, port, username, and password before you touch schema files or query code.

2. Install Drizzle

From your Next.js project:

3. Point Drizzle at DBHost

Add the DBHost connection string to .env.local or the environment file your app already uses:
Use the exact database name and the selected runtime username from DBHost. Keep this private environment file out of source control. Managed runtime credentials do not own tables or run DDL.

4. Add the Drizzle config and schema

MIGRATION_DATABASE_URL is the direct migration connection on migrate.dbhost.app:5432, available while a lease is active. Your app keeps using DATABASE_URL.
That is enough schema to prove the full path works.

5. Create the example table as the owner

Create the matching projects table with your owner PostgreSQL login, for example through an owner SQL client:
Or run drizzle-kit migrate with MIGRATION_DATABASE_URL set. Use the separate runtime credential for the app queries below. Do not treat the pooled runtime URL or role as a migration URL.

6. Create a reusable database client

Use one shared pg pool and hand it to Drizzle:
This keeps development refreshes from creating a new connection pool every time the module reloads.

7. Query from a server component

That is enough to verify the database connection, Drizzle schema, and Next.js render path in one pass.

When DBHost helps most

  • You want PostgreSQL working with Drizzle without managing PgBouncer yourself
  • You want one pooled URL ready on day one
  • You want backups and password resets from the dashboard later
  • You want the option to automate database actions on Pro or Business through the published CLI or REST API

Next steps

Start for Free

Create a DBHost account and provision your first database.

Compare Next.js Paths

See when Drizzle, Prisma, or plain pg is the better fit for your app.
  • See the DBHost quickstart for the shortest path to your first database.
  • See the Next.js + PostgreSQL guide if you want to compare Drizzle with Prisma or plain pg.
  • See the CLI if you want to script database actions from your terminal.
  • See the API reference if your deployment pipeline already speaks HTTP.