npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@db4/cli

v0.1.2

Published

Command line interface for db4

Readme

@db4/cli

(GitHub, npm)

Cloudflare deployment shouldn't require a PhD in wrangler.toml. You want an edge database. Instead, you're debugging binding syntax, managing migration scripts by hand, and praying your local setup matches production.

Four commands. Zero configuration.

Three Steps to the Edge

1. Initialize

npx db4 init

Choose your template:

  • minimal - Simple projects
  • default - Recommended setup
  • full - R2, sharding, replication
db4 init --template full --force

2. Develop

db4 dev

Local Miniflare server with real Durable Objects. Same SQLite storage, same API, same behavior as production.

Dev server: http://localhost:8787
  Health:   /health
  API:      /api/<collection>
db4 dev --port 3000 --verbose

3. Deploy

db4 deploy

Generates wrangler.toml, creates the worker entry, deploys. Done.

db4 deploy --dry-run        # Preview only
db4 deploy --env staging    # Target environment
db4 deploy --force          # Overwrite existing

Migrations

Create:

db4 migrate create add_users_table
// migrations/20260118120000_add_users_table.ts
import type { MigrationContext } from '@db4/core';

export async function up(ctx: MigrationContext): Promise<void> {
  await ctx.sql`CREATE TABLE IF NOT EXISTS users (
    id TEXT PRIMARY KEY,
    email TEXT NOT NULL
  )`;
}

export async function down(ctx: MigrationContext): Promise<void> {
  await ctx.sql`DROP TABLE IF EXISTS users`;
}

export default { up, down };

Run:

db4 migrate up              # Apply pending
db4 migrate up --steps 2    # Apply N migrations
db4 migrate status          # Check state
db4 migrate down            # Rollback last
db4 migrate down --steps 3  # Rollback N migrations

Installation

npm install -g @db4/cli

# Or use npx
npx db4 init

Command Reference

| Command | Description | |---------|-------------| | db4 init | Initialize project | | db4 dev | Start local server | | db4 deploy | Deploy to Cloudflare | | db4 migrate up | Run migrations | | db4 migrate down | Rollback migrations | | db4 migrate status | Show status | | db4 migrate create <name> | Create migration |

Global Options

| Option | Description | |--------|-------------| | --help, -h | Show help | | --version, -V | Show version | | --verbose, -v | Verbose output | | --quiet, -q | Suppress output | | --profile | Performance profiling |

Programmatic API

Every command is a typed function:

import { init, dev, deploy, migrateUp, migrateStatus, migrateCreate } from '@db4/cli';

// Initialize
await init({ cwd: './my-project', template: 'default' });

// Develop
const server = await dev({ port: 8787, verbose: true });
await server.stop();

// Deploy
const { url } = await deploy({ environment: 'production' });

// Migrate
const status = await migrateStatus({ cwd: process.cwd() });
await migrateCreate({ cwd: process.cwd(), name: 'add_users_table' });

The Outcome

With @db4/cli: Zero to deployed edge database in five minutes. init, dev, deploy. Ship it.

Without: Manual wrangler.toml. Cryptic binding errors. Separate local and production configs. Migration tracking in a spreadsheet. Every deploy a ritual of hope.

Related Packages

License

MIT