Qwik banner

Prerequisites

Before you start, make sure you:

1

Add Turso Integration

npm run qwik add turso
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.local.

PRIVATE_TURSO_DATABASE_URL="..."
PRIVATE_TURSO_AUTH_TOKEN="..."
3

Execute SQL

import { tursoClient } from "~/utils/turso";

export const useFrameworks = routeLoader$(
  async (requestEvent: RequestEventBase) => {
    const db = tursoClient(requestEvent["env"]);
    const { rows } = await db.execute("select * from table_name");

    return {
      items: rows,
    };
  }
);

Examples