New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

libsql

Package Overview
Dependencies
Maintainers
1
Versions
133
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libsql

A better-sqlite3 compatible API for libSQL that supports Bun, Deno, and Node

latest
Source
npmnpm
Version
0.5.29
Version published
Weekly downloads
1.6M
44.04%
Maintainers
1
Weekly downloads
 
Created
Source

libSQL API for JavaScript/TypeScript

npm Ask AI

[!IMPORTANT] Turso database and libSQL are two different projects from the same team.

libSQL (this repository) is an open-source fork of SQLite. It extends SQLite with features like embedded replicas and remote access, but inherits SQLite's fundamental limitations such as the single-writer model.

Turso database is a SQLite-compatible database rewritten from scratch in Rust. It is not a fork of SQLite — it is a completely new implementation that goes beyond what any SQLite fork can offer, including concurrent writes and bi-directional sync with offline support. Turso is currently in beta.

If you're starting a new project, you probably want to look into Turso. libSQL is actively maintained, but new features are being developed in Turso.

libSQL is an open source, open contribution fork of SQLite. This source repository contains libSQL API bindings for Node, which aims to be compatible with better-sqlite3, but with opt-in promise API.

Features

  • In-memory and local libSQL/SQLite databases
  • Remote libSQL databases
  • Embedded, in-app replica that syncs with a remote libSQL database
  • Supports Bun, Deno, and Node on macOS, Linux, and Windows.

Installing

You can install the package with:

Node:

npm i libsql

Bun:

bun add libsql

Deno:

Use the npm: prefix for package import:

import Database from 'npm:libsql';

Documentation

Getting Started

To try out your first libsql program, type the following in hello.js:

import Database from 'libsql';

const db = new Database(':memory:');

db.exec("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)");
db.exec("INSERT INTO users (id, name, email) VALUES (1, 'Alice', 'alice@example.org')");

const row = db.prepare("SELECT * FROM users WHERE id = ?").get(1);

console.log(`Name: ${row.name}, email: ${row.email}`);

and then run:

$ node hello.js

To use the promise API, import libsql/promise:

import Database from 'libsql/promise';

const db = new Database(':memory:');

await db.exec("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)");
await db.exec("INSERT INTO users (id, name, email) VALUES (1, 'Alice', 'alice@example.org')");

const stmt = await db.prepare("SELECT * FROM users WHERE id = ?");
const row = stmt.get(1);

console.log(`Name: ${row.name}, email: ${row.email}`);

Connecting to a local database file

import Database from 'libsql';

const db = new Database('hello.db');

Connecting to a Remote libSQL server

import Database from 'libsql';

const url = process.env.LIBSQL_URL;
const authToken = process.env.LIBSQL_AUTH_TOKEN;

const opts = {
  authToken: authToken,
};

const db = new Database(url, opts);

Creating an in-app replica and syncing it

import libsql

const opts = { syncUrl: "<url>", authToken: "<optional auth token>" };
const db = new Database('hello.db', opts);
db.sync();

Creating a table

db.exec("CREATE TABLE users (id INTEGER, email TEXT);")

Inserting rows into a table

db.exec("INSERT INTO users VALUES (1, 'alice@example.org')")

Querying rows from a table

const row = db.prepare("SELECT * FROM users WHERE id = ?").get(1);

Developing

To build the libsql package, run:

LIBSQL_JS_DEV=1 npm run build

You can then run the integration tests with:

export LIBSQL_JS_DEV=1
npm link
cd integration-tests
npm link libsql
npm test

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in libSQL by you, shall be licensed as MIT, without any additional terms or conditions.

Keywords

libsql

FAQs

Package last updated on 25 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts