- Retrieve database credentials
- Connect to a remote Turso database
- Execute a query using SQL
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.
Connect to your database
- @tursodatabase/serverless
- @libsql/client
@libsql/client API, use the compat module:Execute a query using SQL
- @tursodatabase/serverless
- @libsql/client
Sync
If you need to sync your local database with a remote Turso Cloud database (local reads and writes with push/pull to the cloud), use Turso Sync. Turso Sync is built on the Turso Database engine and provides true local-first sync with explicit
push() and pull() operations.