Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tursodatabase/libsql-client-ts
TypeScript/JavaScript client API for libSQL
https://github.com/tursodatabase/libsql-client-ts
client javascript libsql sqlite typescript
Last synced: 4 days ago
JSON representation
TypeScript/JavaScript client API for libSQL
- Host: GitHub
- URL: https://github.com/tursodatabase/libsql-client-ts
- Owner: tursodatabase
- License: mit
- Created: 2023-02-28T14:49:32.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-29T13:20:52.000Z (about 1 month ago)
- Last Synced: 2024-10-30T00:44:45.121Z (about 1 month ago)
- Topics: client, javascript, libsql, sqlite, typescript
- Language: TypeScript
- Homepage: https://docs.turso.tech/sdk/ts/quickstart
- Size: 1.13 MB
- Stars: 248
- Watchers: 9
- Forks: 35
- Open Issues: 88
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-turso - JavaScript/TypeScript SDK
README
libSQL TypeScript
Databases for all TypeScript and JS multi-tenant apps.
Turso ยท
Docs ยท
Quickstart ยท
SDK Reference ยท
Blog & Tutorials## Features
- ๐ Works offline with [Embedded Replicas](https://docs.turso.tech/features/embedded-replicas/introduction)
- ๐ Works with remote Turso databases
- โจ Works with Turso [AI & Vector Search](https://docs.turso.tech/features/ai-and-embeddings)
- ๐ Supports [encryption at rest](https://docs.turso.tech/libsql#encryption-at-rest)## Install
```bash
npm install @libsql/client
```## Quickstart
The example below uses Embedded Replicas and syncs every minute from Turso.
```ts
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](examples/local) | Uses libsql with a local SQLite file. Creates database, inserts data, and queries. |
| [remote](examples/remote) | Connects to a remote database. Requires environment variables for URL and auth token. |
| [sync](examples/sync) | Demonstrates synchronization between local and remote databases. |
| [batch](examples/batch) | Executes multiple SQL statements in a single batch operation. |
| [transactions](examples/transactions) | Shows transaction usage: starting, performing operations, and committing/rolling back. |
| [memory](examples/memory) | Uses an in-memory SQLite database for temporary storage or fast access. |
| [vector](examples/vector) | Works with vector embeddings, storing and querying for similarity search. |
| [encryption](examples/encryption) | Creates and uses an encrypted SQLite database, demonstrating setup and data operations. |## Documentation
Visit our [official documentation](https://docs.turso.tech/sdk/ts).
## Support
Join us [on Discord](https://tur.so/discord-ts) to get help using this SDK. Report security issues [via email](mailto:[email protected]).
## Contributors
See the [contributing guide](CONTRIBUTING.md) to learn how to get involved.
![Contributors](https://contrib.nn.ci/api?repo=tursodatabase/libsql-client-ts)