Co-authored by
Turso is multi-tenant database platform built for all types of apps, including AI apps with on-device RAG, local-first vector search, offline writes, and privacy-focused data access with low latency.
Here’s how to switch from Neon to Turso for your JTBDOS
project.
1. Sign up to Turso
You can use the Dashboard, or the CLI to manage your account, database, and auth tokens. We’ll be using the CLI throughout this guide.2. Create a Database
Create a new database and give it a name using the Turso CLI:Terminal
Terminal
3. Create a Database Auth Token
You will need to create an auth token to connect to your Turso database:Terminal
4. Update your environment variables
Update your environment variables to use the new Turso connection string:apps/database/.env
apps/app/.env.local
packages/env/index.ts
, add DATABASE_AUTH_TOKEN
to the server
and runtimeEnv
objects:
5. Install @libsql/client
The@libsql/client
is used to connect to the hosted Turso database.
Uninstall the existing dependencies for Neon…
Terminal
Terminal
6. Update Webpack configuration
Openpackages/next-config/index.ts
and add @libsql/client
to the list of externals:
packages/next-config/index.ts
7. Update the database connection code
Openpackages/database/index.ts
and make the following changes:
packages/database/index.ts
8. Apply schema changes
Now connect to the Turso database using the CLI:Terminal
9. Update application code
Now wherever you would usually call Prisma, use thelibsql
client instead:
packages/app/app/(authenticated)/page.tsx