@nextlyhq/adapter-sqlite
SQLite database adapter for Nextly. Built on better-sqlite3 for synchronous file-based persistence.
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 isdocker 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-sqlite3Quick usage
Nextly selects the adapter from your .env file. Install the package and set:
DB_DIALECT=sqlite
DATABASE_URL=file:./data/nextly.dbThe 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.
RETURNINGclause. Supported (SQLite 3.35+).
Main exports
SqliteAdapter: the adapter classcreateSqliteAdapter: factory for programmatic useisSqliteAdapter: type guard- Type exports:
SqliteAdapterConfig
Compatibility
| Tool | Version |
|---|---|
| Node.js | 20+ |
better-sqlite3 |
11+ |
nextly |
0.0.x |
Documentation
Related packages
@nextlyhq/adapter-postgres: recommended for production@nextlyhq/adapter-mysql