diff --git a/.github/cover.png b/.github/cover.png new file mode 100644 index 0000000..9b16b75 Binary files /dev/null and b/.github/cover.png differ diff --git a/packages/libsql-client/README.md b/packages/libsql-client/README.md index 0510fa4..6827337 100644 --- a/packages/libsql-client/README.md +++ b/packages/libsql-client/README.md @@ -1,51 +1,125 @@
-
-
- Turso + TypeScript / JS
+
+
+
- SQLite for Production. Powered by libSQL. + Databases for all TypeScript and JS multi-tenant apps.
- Turso · - Quickstart · - Examples · + Turso · Docs · - Discord · - Blog & Tutorials + 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 client.batch( + [ + "CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT)", + { + sql: "INSERT INTO users 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 -1. [Turso Quickstart](https://docs.turso.tech/quickstart) — Learn how create and connect your first database. -2. [SDK Quickstart](https://docs.turso.tech/sdk/ts/quickstart) — Learn how to install and execute queries using the libSQL client. -3. [SDK Reference](https://docs.turso.tech/sdk/ts/reference) — Dive deeper with the libSQL SDK reference and examples. +Visit our [official documentation](https://docs.turso.tech/sdk/kotlin). + +## Support + +Join us [on Discord](https://tur.so/discord-ts) to get help using this SDK. Report security issues [via email](mailto:security@turso.tech). -### What is Turso? +## Contributors -[Turso](https://turso.tech) is a SQLite-compatible database built on [libSQL](https://docs.turso.tech/libsql), the Open Contribution fork of SQLite. It enables scaling to hundreds of thousands of databases per organization and supports replication to any location, including your own servers, for microsecond-latency access. +See the [contributing guide](CONTRIBUTING.md) to learn how to get involved. -Learn more about what you can do with Turso: +![Contributors](https://contrib.nn.ci/api?repo=tursodatabase/libsql-client-ts) -- [Embedded Replicas](https://docs.turso.tech/features/embedded-replicas) -- [Platform API](https://docs.turso.tech/features/platform-api) -- [Data Edge](https://docs.turso.tech/features/data-edge) -- [Branching](https://docs.turso.tech/features/branching) -- [Point-in-Time Recovery](https://docs.turso.tech/features/point-in-time-recovery) -- [Scale to Zero](https://docs.turso.tech/features/scale-to-zero) + + +