Skip to content

Files

Latest commit

Mar 24, 2025
8f0bdde · Mar 24, 2025

History

History

libsql-client

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Mar 19, 2025
May 20, 2024
Nov 15, 2024
Jan 7, 2025
May 20, 2024
Jan 18, 2024
Mar 24, 2025
Jan 18, 2024
May 20, 2024
May 20, 2024
Jan 18, 2024
Jan 18, 2024

libSQL TypeScript

libSQL TypeScript

Databases for all TypeScript and JS multi-tenant apps.

Turso · Docs · Quickstart · SDK Reference · Blog & Tutorials

MIT License Discord Contributors Weekly downloads Examples

Features

Install

npm install @libsql/client

Quickstart

The example below uses Embedded Replicas and syncs every minute from Turso.

import { createClient } from "@libsql/client";

export const turso = createClient({
    url: "file:local.db",
    syncUrl: process.env.TURSO_DATABASE_URL,
    authToken: process.env.TURSO_AUTH_TOKEN,
    syncInterval: 60000,
});

await turso.batch(
    [
        "CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT)",
        {
            sql: "INSERT INTO users(name) VALUES (?)",
            args: ["Iku"],
        },
    ],
    "write",
);

await turso.execute({
    sql: "SELECT * FROM users WHERE id = ?",
    args: [1],
});

Examples

Example Description
local Uses libsql with a local SQLite file. Creates database, inserts data, and queries.
remote Connects to a remote database. Requires environment variables for URL and auth token.
sync Demonstrates synchronization between local and remote databases.
batch Executes multiple SQL statements in a single batch operation.
transactions Shows transaction usage: starting, performing operations, and committing/rolling back.
memory Uses an in-memory SQLite database for temporary storage or fast access.
vector Works with vector embeddings, storing and querying for similarity search.
encryption Creates and uses an encrypted SQLite database, demonstrating setup and data operations.
ollama Similarity search with Ollama and Mistral.

Documentation

Visit our official documentation.

Support

Join us on Discord to get help using this SDK. Report security issues via email.

Contributors

See the contributing guide to learn how to get involved.

Contributors

good first issue