@tursodatabase/serverless is the lightest option with zero native dependencies. Use @libsql/client if you need a battle-tested driver today with ORM integration.
@tursodatabase/serverless
@libsql/client
Raw HTTP
The @tursodatabase/serverless package connects to Turso using only the fetch API — no native dependencies, making it the smallest option for edge and serverless runtimes.
1
Install
npm install @tursodatabase/serverless
2
Connect and query
import { connect } from "@tursodatabase/serverless";const conn = connect({ url: process.env.TURSO_DATABASE_URL, authToken: process.env.TURSO_AUTH_TOKEN,});const stmt = conn.prepare("SELECT * FROM users WHERE id = ?");const row = await stmt.get([123]);
For compatibility with the libSQL client API, use the compat module:
import { createClient } from "@tursodatabase/serverless/compat";const client = createClient({ url: process.env.TURSO_DATABASE_URL, authToken: process.env.TURSO_AUTH_TOKEN,});const result = await client.execute("SELECT * FROM users WHERE id = ?", [123]);
The @libsql/client package is the production-ready libSQL driver used across the Turso ecosystem. Use the /web import for serverless and edge runtimes.
1
Install
npm install @libsql/client
2
Connect and query
import { createClient } from "@libsql/client/web";const client = createClient({ url: process.env.TURSO_DATABASE_URL!, authToken: process.env.TURSO_AUTH_TOKEN!,});const result = await client.execute({ sql: "SELECT * FROM users WHERE id = ?", args: [123],});
Use @libsql/client/web instead of @libsql/client for edge and serverless runtimes. The /web import uses the HTTP protocol.
You can also send queries directly over HTTP using any HTTP client.
Make sure to update the stmt.sql to select from a table you already have.Bound parameter examples included on the Reference Page,
4
Execute HTTP Request
Depending on your language, you can use a HTTP client library to send the request to the URL you created as well as the Authorization header set to the token you created, and the request body as JSON with your SQL statement.You must append to the Base URL the actual pipeline URL that accepts requests — /v2/pipeline.