Turso Cloud SDKs Official SDKs TypeScript Guides
Nuxt + Turso
Set up Turso in your Nuxt project in minutes

Before you start, make sure you:
- Install the Turso CLI
- Sign up or login to Turso
- Have a Nuxt app — learn more
1. Install the libSQL SDK
Begin by installing the @libsql/client dependency in your project:
npm install @libsql/client
pnpm install @libsql/client
yarn add @libsql/client
deno add npm:@libsql/client
2. Configure 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.
NUXT_TURSO_DATABASE_URL=
NUXT_TURSO_AUTH_TOKEN=
3. Configure variables inside Nuxt’s runtime config.
export default defineNuxtConfig({
runtimeConfig: {
turso: {
databaseUrl: "",
authToken: "",
},
},
});
NOTE
Make sure that names of the keys in the runtimeConfig object match the names
of your environment variables. Read more about this
here.
4. Configure libSQL Client.
import { createClient } from "@libsql/client";
// You can optionally pass in the event to useRuntimeConfig
// import { H3Event } from "h3";
export function useTurso(/* event: H3Event */) {
const { turso } = useRuntimeConfig(/* event */);
return createClient({
url: turso.databaseUrl,
authToken: turso.authToken,
});
}
5. Execute SQL
export default defineEventHandler(async (event) => {
const client = useTurso(/* event */);
const { rows } = await client.execute("select * from table_name");
return {
data: {
items: rows,
},
};
});
Examples
Synced from official Turso documentation (
tursodatabase/turso-docs
· MIT License)
Official Docs ↗