DocsDatabases

Choose a database for Deno

Select among PostgreSQL, SQLite, MongoDB, Redis, Supabase, and Deno KV

Deno can use mature database drivers through npm compatibility as well as Web and JSR modules. Choose from the data model, transaction needs, and hosting environment—not from which package looks most “Deno-native.”

Data layerGood forDeno access
PostgreSQLrelational data, transactions, complex queriesnpm:postgres, npm:pg, Drizzle, Kysely
SQLitesingle-node, embedded, tests, small servicesnode:sqlite or compatible libraries; verify runtime version
MongoDBdocument models and existing Mongo stacksofficial npm driver or Mongoose
Rediscache, rate limits, short-lived stateofficial npm client or compatible service
Supabasemanaged Postgres plus Auth/Storageofficial npm SDK or direct Postgres
Deno KVsimple key-value and atomic operationsDeno.openKv(); verify hosting support first

Common connection boundary

deno run \
  --allow-env=DATABASE_URL \
  --allow-net=db.example.com:5432 \
  src/main.ts
  • Reuse a pool over the module or application lifecycle; do not create one per request.
  • Load secrets only from environment or a secret store, never source, logs, or error responses.
  • Treat migrations as a release step; schema mutation during app startup multiplies concurrency risk.
  • Serverless instances scale concurrently, so budget connections across the maximum instance count.
  • Test connection failure, rollback, unique constraints, and timeouts.

The new Deno Deploy supports linked PostgreSQL, timeline isolation, and Deno KV, but data and migration policies still need to be designed per timeline. See Deploy data and cron.

Official references: Connecting to databases and Deno database examples.

Type to search all documentation.