Guides
Elysia + Turso
Set up Turso in your Elysia project in minutes.
Prerequisites
Before you start, make sure you:
- Install the Turso CLI
- Sign up or login to Turso
- Have an Elysia app — learn more
1
Install the libSQL SDK
Begin by installing the @libsql/client
dependency in your project:
2
Retrieve database credentials
Get the database URL:
turso db show --url <database-name>
Get the database authentication token:
turso db tokens create <database-name>
Assign credentials to the environment variables inside .env
.
TURSO_DATABASE_URL=
TURSO_AUTH_TOKEN=
3
Configure libSQL client
4
Execute SQL
import { Elysia } from "elysia";
import { turso } from "./lib/turso";
const app = new Elysia().get("/items", async () => {
const { rows } = await turso.execute("SELECT * FROM items");
return rows;
});