Skip to main content
Drizzle banner
Drizzle uses @libsql/client for Turso integration. There is also beta support for @tursodatabase/database for local/embedded use cases.

Prerequisites

Before you start, make sure you:
1

Install Drizzle and the libSQL SDK

Finish by updating package.json to include three new scripts:
2

Retrieve database credentials

Get the database URL:
Get the database authentication token:
Assign credentials to the environment variables inside .env.
3

Create a Drizzle schema

db/schema.ts
4

Configure Drizzle Kit

Create the file drizzle.config.ts in the root of your project with the following:
drizzle.config.ts
We’re using dotenv above, but if you’re using something like Next.js, Remix, Astro, or Vite, you can use their built-in environment variables manager to source these values.
5

Connect Drizzle with libSQL

6

Database migrations

Drizzle can generate and apply database migrations with drizzle-kit.Whenever you make changes to the schema, run db:generate:
Now apply these changes to the database with db:migrate:
7

Query

8

Connect Drizzle Studio

Vector Embeddings

You can extend Drizzle to support Turso’s native vector — learn more.
1

Define custom vector type

Inside db/schema.ts, add the following:
2

Create a table with a vector column

Now where you define the schema, invoke float32Array to create a column that stores vectors:
3

Create a vector index

You will need to use raw SQL to create the index:
4

Insert vector data

5

Query vector data

Calculate vector distance:
Perform efficient nearest neighbor search:
Remember to create appropriate indexes for efficient vector operations and adjust vector dimensions as needed for your use case.