npm.io
0.0.2-alpha.26 • Published 1h ago

@nextlyhq/adapter-sqlite

Licence
MIT
Version
0.0.2-alpha.26
Deps
3
Size
152 kB
Vulns
0
Weekly
353
Stars
39

@nextlyhq/adapter-sqlite

SQLite database adapter for Nextly. Built on better-sqlite3 for synchronous file-based persistence.

npm License Status

Nextly is in alpha. APIs may change before 1.0. Pin exact versions in production.

SQLite is for local demos and quick experiments only. It is single-writer, file-based, has no SSL, and emulates several features (see Dialect notes below). The adapter exists so you can try Nextly without provisioning a database server. For any real project, even local development, use @nextlyhq/adapter-postgres. The fastest way to run Postgres locally is docker compose up -d postgres.

What it is

The SQLite adapter for Nextly. Use this for one-off local demos or quick experiments where setting up a database server would be friction.

For any project beyond a quick demo, use @nextlyhq/adapter-postgres. PostgreSQL has the full feature set Nextly is designed around; SQLite emulates a subset.

Installation

pnpm add @nextlyhq/adapter-sqlite better-sqlite3

Quick usage

Nextly selects the adapter from your .env file. Install the package and set:

DB_DIALECT=sqlite
DATABASE_URL=file:./data/nextly.db

The path can be relative (resolved against the project root) or absolute. The directory must exist.

Required environment variables

Variable Required? Default Notes
DATABASE_URL yes (none) file:./path/to/db.sqlite or absolute path.
DB_DIALECT recommended (auto-detected from URL) Set explicitly to silence the warning at boot.

Programmatic usage (advanced)

For test harnesses or scripts:

import { createSqliteAdapter } from "@nextlyhq/adapter-sqlite";

const adapter = createSqliteAdapter({
  url: process.env.DATABASE_URL!,
});

await adapter.connect();

Most users do not need this.

Supported SQLite versions

  • SQLite 3.38 or newer required (bundled with better-sqlite3)

Dialect notes

  • Single writer. SQLite serializes writes; concurrent transactions queue. Fine for one user, painful for production traffic.
  • No SSL or TLS. Not applicable to a local file.
  • Limited types. No native arrays, no JSONB; JSON is stored as TEXT. ILIKE is emulated as LOWER(...) LIKE LOWER(...).
  • Savepoints. Supported.
  • RETURNING clause. Supported (SQLite 3.35+).

Main exports

  • SqliteAdapter: the adapter class
  • createSqliteAdapter: factory for programmatic use
  • isSqliteAdapter: type guard
  • Type exports: SqliteAdapterConfig

Compatibility

Tool Version
Node.js 20+
better-sqlite3 11+
nextly 0.0.x

Documentation

License

MIT

Keywords