IndexPackages

create-cloud-db

CLI to create a Turso database and write TURSO_* env vars to .env file

DocumentationOpen in StackBlitz
NPM Monthly Downloadsnpm versionNPM Total DownloadsTypeScript typesInstall size

🤖 Agent skillnpx skills@latest add https://github.com/OpenSourceAGI/dev-tools-starter-agent --skill create-cloud-db (what it covers)

create-cloud-db is a small CLI that creates a Turso database and manages the TURSO_DATABASE_URL and TURSO_AUTH_TOKEN values in your local .env file.

It is designed for quick local setup so you can be ready to connect from Node, frameworks, or serverless environments with minimal manual configuration.

Installation

You must first login to turso with:

bun i -g turso
turso auth login

# or
bun x turso auth login

Then run:

# will ask for name
npm create cloud-db

# or
npx create-cloud-db

# or
npx create-cloud-db [myapp-db]

Or install globally:

npm install -g create-cloud-db
create-cloud-db myapp-db

What it does

When you run the command, the CLI:

  1. Ensures you are logged into Turso via turso auth login.
  2. Creates a Turso database if it does not already exist.
  3. Generates a database URL and an auth token via the Turso CLI.
  4. Overwrites (not appends) the TURSO_DATABASE_URL and TURSO_AUTH_TOKEN entries in your local .env file.

After running, your .env file will contain something like:

TURSO_DATABASE_URL=libsql://your-db-name.region.turso.io
TURSO_AUTH_TOKEN=eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9...

Add to package.json

    "db:create": "create-cloud-db",
    "db:generate": "drizzle-kit generate",
    "db:push": "drizzle-kit push",
    "db:studio": "drizzle-kit studio",

Environment file behavior

  • The CLI reads your existing .env file if present.
  • It updates or inserts TURSO_DATABASE_URL and TURSO_AUTH_TOKEN keys.
  • The .env file is rewritten, so old placeholder values are removed and replaced with valid values.

Example with Drizzle

// drizzle.config.ts

import { defineConfig } from 'drizzle-kit';

export default defineConfig({
  dialect: 'turso',
  schema: './src/lib/db/schema.ts',
  out: './drizzle',
  dbCredentials: {
    url: process.env.TURSO_DATABASE_URL || 'file:./localdb.sqlite',
    authToken: process.env.TURSO_AUTH_TOKEN,
  },
});

📝 License

MIT License - Star this repo so it can grow features! 🌟


PRs Welcome

Please star this repo for updates! 🌟


Source: packages/create-cloud-db/README.md

Last updated on

On this page