superapp
Backend

Databases

Connect to any database with Drizzle-compatible adapters.

Chat in Claude

Every database in @superapp/backend is accessed through a Drizzle-compatible adapter. The adapter architecture mirrors Drizzle ORM's driver pattern -- a core dialect layer handles SQL generation, and a thin driver adapter handles the connection.

import { createEngine } from '@superapp/backend'

const engine = createEngine({
  connections: {
    main: process.env.PG_URL!,
  },
})

How Adapters Work

Adapters follow a two-layer architecture, identical to how Drizzle ORM structures its database support:

  1. Core dialect -- Defines SQL generation, column types, query builders, and dialect-specific features (pg-core, mysql-core, sqlite-core)
  2. Driver adapter -- A thin wrapper around a specific JavaScript database driver that handles connection management, session handling, and migrations
┌─────────────────────────────────────┐
│          Your Application           │
├─────────────────────────────────────┤
│       @superapp/backend engine      │
├──────────┬──────────┬───────────────┤
│  pg-core │mysql-core│  sqlite-core  │  ← Core dialects
├──────────┼──────────┼───────────────┤
│    pg    │  mysql2  │better-sqlite3 │  ← Driver adapters
└──────────┴──────────┴───────────────┘

Supported Databases

@superapp/backend supports every database that Drizzle ORM supports. Below is the full matrix organized by dialect.

PostgreSQL

AdapterDriverBest for
node-postgrespgStandard Node.js apps
postgres-jspostgresHigh-performance Node.js
neon-serverless@neondatabase/serverlessNeon (WebSocket)
neon-http@neondatabase/serverlessNeon (HTTP, edge/serverless)
vercel-postgres@vercel/postgresVercel managed Postgres
supabase@supabase/supabase-jsSupabase Postgres
xata-httpXata HTTP APIXata serverless
pglite@electric-sql/pgliteIn-browser/WASM Postgres
aws-data-apiAWS RDS Data APIAurora Serverless
bun-sqlBun.sqlBun runtime

MySQL

AdapterDriverBest for
mysql2mysql2Standard Node.js apps
planetscale-serverless@planetscale/databasePlanetScale (serverless HTTP)
tidb-serverlessTiDB CloudTiDB Cloud serverless

SQLite

AdapterDriverBest for
better-sqlite3better-sqlite3Node.js (synchronous)
libsql@libsql/clientTurso / LibSQL
d1Cloudflare D1Cloudflare Workers
durable-sqliteCloudflare Durable ObjectsDurable Object storage
bun-sqlitebun:sqliteBun runtime
expo-sqliteexpo-sqliteReact Native (Expo)
op-sqliteop-sqliteReact Native (high-performance)
sql-jssql.jsIn-browser WASM SQLite

SingleStore

AdapterDriverBest for
singlestoreSingleStore driverDirect connection

Gel (formerly EdgeDB)

AdapterDriverBest for
gelGel clientGel database

Built-in Providers

The engine ships with three built-in providers that require zero configuration beyond a connection string:

ProviderConnection formatReadWriteDriver
PostgreSQL'postgres://...'YesYespg
MySQL'mysql://...'YesYesmysql2
SQLite'./path/to/file.db'YesYesbetter-sqlite3
CSV{ directory: './data/' }YesNobuilt-in

For any other database from the supported list above, register a custom provider using the Drizzle adapter pattern.

Provider Interface

Every provider -- built-in or custom -- exports a single object that satisfies the IntegrationProvider interface:

interface IntegrationProvider {
  type: string
  connect: (config: ConnectionConfig) => Promise<DriverConnection>
  disconnect: (connection: DriverConnection) => Promise<void>
  introspect: (connection: DriverConnection) => Promise<TableSchema[]>
  capabilities: {
    read: boolean
    write: boolean
    transactions: boolean
  }
}

The connect method initializes the native driver connection pool. The engine calls it once on startup (or when a connection is added via the admin UI) and maintains the pool for the lifetime of the process.

Multiple Connections

Pass all connections in the connections object. The engine infers the type from the protocol or format:

const engine = createEngine({
  connections: {
    main: process.env.PG_URL!,
    warehouse: process.env.MYSQL_URL!,
    reports: { directory: './data/reports' },
  },
})

Next Steps

  • PostgreSQL -- Full CRUD with Postgres
  • MySQL -- Full CRUD with MySQL
  • SQLite -- Local file-based databases
  • CSV -- Read-only CSV file queries
  • Custom Providers -- Build your own Drizzle-compatible provider

On this page