A Knex dialect for @libsql/client.
npm install knex @libsql/client knex-libsql-clientLocal database:
import { createLibsqlKnex } from "knex-libsql-client";
const db = createLibsqlKnex({
connection: {
url: "file:./my.db",
initCommands: ["PRAGMA foreign_keys = ON"],
},
});
const rows = await db("users").select("*");In-memory database:
const db = createLibsqlKnex({
connection: {
url: ":memory:",
initCommands: ["PRAGMA foreign_keys = ON"],
},
});Remote database (Turso / LibSQL server):
const db = createLibsqlKnex({
connection: {
url: "libsql://your-db.turso.io",
authToken: process.env.TURSO_AUTH_TOKEN,
initCommands: ["PRAGMA foreign_keys = ON"],
},
});| Option | Description |
|---|---|
url |
Database URL. Use file:./path/to/db.sqlite for a local file, :memory: for in-memory, or an https:// / wss:// URL for a remote LibSQL server (e.g. Turso). |
filename |
Alternative to url for local files — converted to a file: URL automatically. |
authToken |
Auth token for remote LibSQL connections. |
initCommands |
Array of SQL statements to execute on each new connection, in order. Useful for PRAGMAs such as PRAGMA foreign_keys = ON. A failure in any command discards the connection. |
After a fresh clone:
mkdir .plans # or `npx alignfirst plans setup <clone-path>` with the team plans repository
npx -y alignfirst workspace setupThe tooling runs AlignFirst through npx alignfirst. Install it globally (npm install -g alignfirst) to use the bare alignfirst command.
See DEVELOPERS.md for the development workflow.
MIT