Skip to content

FlashQL Guide ​

Unlike the other clients, FlashQL is not a connector to an external database. It is the database itself, a full SQL runtime that runs in the same process as your app.

Use FlashQL when you want the database to run inside your application, in Node.js, the browser, a worker, or an edge runtime.

See the FlashQL Overview for architecture and capabilities.


Setup ​

js
import { FlashQL } from '@linked-db/linked-ql/flashql';

const db = new FlashQL();
await db.connect();

const result = await db.query('SELECT 1::text AS result');
console.log(result.rows);

await db.disconnect();

Configuration Shape ​

FlashQL is configured entirely at construction time and all parameters are optional:

OptionTypeDefaultPurpose
dialect'postgres' | 'mysql''postgres'default SQL dialect
keyvalKeyvalnullenables persistence
getUpstreamClient(origin) => clientnullresolves upstream sources
versionStopstring | objectnullboot at a historical point
overwriteForwardbooleanfalseallow branching from history
autoSyncbooleantruerun sync on connect

Example:

js
const keyval = new IndexedDBKV({ path: ['my-app'] });
const upstream = new EdgeClient({ url: remoteUrl });

const db = new FlashQL({
  dialect: 'mysql',
  keyval,
  getUpstreamClient: () => upstream,
});

Persistence ​

FlashQL supports persistence via the keyval parameter.

See Persistence.


Upstream Connections ​

FlashQL connects to external databases via the getUpstreamClient() callback.

See Federation, Materialization, and Sync.


Realtime Notes ​

Realtime queries, WAL subscriptions, and sync are built into the runtime. No database-level setup is required.


Additional Reading ​

If you want to learn about...Go to...
the broader FlashQL architectureFlashQL Overview
the common API contractCore API

MIT Licensed