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

@nerdfolio/drizzle-d1-helpers

v0.1.5

Published

Helpers to run drizzle & d1 in the local dev environment. Simplify access to local miniflare sqlite file and to remote d1 via http proxy

Readme

drizzle-d1-helpers

Why is this needed?

In production, it's easy to access D1 with Drizzle via Cloudflare bindings. However, during development, local scripting, or drizzle-kit, different mechanisms are needed to acquire access to the D1 database. This is illustrated in the table below

| Scenario | Solution provided or simplified by this package | Applicable to | | ---------------------------- | -------------------------------------------------------------------- | ----------------------------- | | server dev local db | getPlatformProxy() to obtain miniflare binding | | running scripts on local db | getPlatformProxy() to obtain miniflare binding | drizzle-seed, any node script | | running scripts on remote db | custom d1-http driver | drizzle-seed, any node script | | drizzle-kit on local db | parse wrangler config and locate the miniflare sqlite file | migrate, studio | | drizzle-kit on remote db | parse wrangler config to get databaseId and format access credential | migrate, studio |

Installation


pnpm add -D @nerdfolio/drizzle-d1-helpers

Usage

Obtain a D1Helper for a particular D1 binding

import { D1Helper } from "@nerdfolio/drizzle-d1-helpers";

const helper = D1Helper.get("MY_D1_DB");

// If you only have 1 D1 binding in your wrangler config, you don't
// have to specify it's name.
// If you have more than 1 binding, this code will throw

const helper2 = D1Helper.get();


// If you have bindings defined for a specific worker environment

const stagingEnvHelper = D1Helper.get("MY_D1_DB", {environment: "staging"})

Get proxy credentials

console.log(
   D1Helper.get(MY_D1_BINDING).withCfCredentials(
      process.env.CLOUDFLARE_ACCOUNT_ID,
      process.env.CLOUDFLARE_D1_TOKEN
   ).proxyCredentials
);

//
// {accountId: "....", token: "....", databaseId: "..."}
//

Get local sqlite file or credentials

console.log(D1Helper.get().sqliteLocalFileCredentials);

// {url: "file:.wrangler/state/v3/d1/miniflare-D1DatabaseObject/a8bef33e667eba6dbefcb5090b02c4719daf1851f75b3901eda4b71e462fa5d2.sqlite"}

// If you use `wrangler dev` with the `--persist-to` dir, this info lives out side of
// wrangler config, so you must set it in order for D1Helper to calculate the local
// file path correctly

console.log(D1Helper.get().withPersistTo("my-wrangler-path")).sqliteLocalFile;

// my-wrangler-path/d1/miniflare-D1DatabaseObject/a8bef33e667eba6dbefcb5090b02c4719daf1851f75b3901eda4b71e462fa5d2.sqlite
//

Acquire d1 and run an async function with it

// Using D1Helper for proxy d1
D1Helper.get()
   .withCfCredentials(
      process.env.CLOUDFLARE_ACCOUNT_ID,
      process.env.CLOUDFLARE_D1_TOKEN
   )
   .useProxyD1(async (db) => {
      // run some code with db
   });

// Using D1Helper for local sqlite d1
D1Helper.get().useLocalD1(async (db) => {
   // run some code with db
});

// There are also useProxyD1 and useLocalD1
useProxyD1({ accoundId, token, databaseId }, async () => {
   // do work
});

useLocalD1("MY_D1", async (db) => {
   // do work
});

useLocalD1("MY_D1", async (db) => {}, "staging");

Happy Coding!