In this Rust quickstart we will learn how to:Documentation Index
Fetch the complete documentation index at: https://docs.turso.tech/llms.txt
Use this file to discover all available pages before exploring further.
- Install the Turso crate
- Connect to a local or remote database
- Execute a query using SQL
- Sync changes to the cloud
Recommended: turso (Local + Cloud Sync)
turso is the recommended crate for running a local database, including synchronizing it to and from Turso Cloud. It is built on the Turso Database engine — a ground-up rewrite of SQLite with concurrent writes (MVCC), async I/O, and native Rust async/await support.
Sync (push and pull)
If you need to sync your local database with Turso Cloud, enable the All reads and writes happen against the local database file — fast, offline-capable.
sync feature:push() sends your changes to the cloud. pull() brings remote changes down. See the reference for checkpoint, stats, and encryption. See Turso Sync for details on conflict resolution and more.You can test sync locally without a Turso Cloud account by starting a local sync server:Then use
http://127.0.0.1:8080 as the remote URL (no auth token needed). See Turso Database quickstart for how to install tursodb.Remote Access (Over-the-Wire)
If your application needs to query a Turso Cloud database directly over the network (e.g., from a web server or serverless function), use thelibsql crate with the remote feature. It connects over HTTP — no local file needed, no C compiler required.
For most applications, we recommend running a local database with sync (
turso::sync) instead — it gives you faster reads, offline support, and lower latency. Remote access is useful when you cannot store a local database file (e.g., stateless serverless environments).Retrieve database credentials
You will need an existing database to continue. If you don’t have one, create one.Get the database URL:Get the database authentication token:Assign credentials to the environment variables inside
.env.You will want to store these as environment variables.
Legacy: libsql (Embedded Replicas)
See the reference for legacy documentation on embedded replicas if you have an existinglibsql codebase.