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

drizzle-studio-middleware

v1.0.0

Published

Mount Drizzle Studio as middleware in your Hono/Express app

Readme

drizzle-studio-middleware

Mount Drizzle Studio as middleware in your Hono app. No need to run a separate drizzle-kit studio process.

Note: The Drizzle Studio frontend is hosted at https://local.drizzle.studio and is not open source. This package only provides the backend API that the frontend connects to.

Install

pnpm add drizzle-studio-middleware

Peer dependencies: hono (>=4), drizzle-orm (>=0.30)

Quick Start (High-level API)

import { serve } from '@hono/node-server'
import { createStudioMiddleware, getStudioUrl } from 'drizzle-studio-middleware'
import * as schema from './db/schema'

const studioApp = await createStudioMiddleware({
  dialect: 'postgresql',
  dbUrl: process.env.DATABASE_URL!,
  schema: { public: schema },
  casing: 'snake_case',
})

// Studio frontend requires the API at the root path of a host:port,
// so run it on a dedicated port.
serve({ fetch: studioApp.fetch, port: 4983 }, () => {
  console.log(`Drizzle Studio: ${getStudioUrl('127.0.0.1', 4983)}`)
})

Low-level API (Custom Proxy)

If you need full control over how queries are executed:

import { createHash } from 'crypto'
import { createStudioApp } from 'drizzle-studio-middleware'
import type { ProxyParams } from 'drizzle-studio-middleware'
import * as schema from './db/schema'

const studioApp = createStudioApp({
  dbHash: createHash('sha256').update(dbUrl).digest('hex'),
  dialect: 'postgresql',
  packageName: 'postgres',
  proxy: async (params: ProxyParams) => {
    // Execute SQL using your own database client
    return await db.unsafe(params.sql, params.params)
  },
  transactionProxy: async (queries) => {
    const results: any[] = []
    await db.begin(async (sql) => {
      for (const q of queries) {
        results.push(await sql.unsafe(q.sql))
      }
    })
    return results
  },
  customDefaults: [],
  schema: { public: schema },
  relations: {},
})

Usage with Existing Hono App

The Drizzle Studio frontend (local.drizzle.studio) sends requests to the root path of a given host:port. It does not support custom base paths like /studio. Therefore, the Studio API must run on its own port:

import { Hono } from 'hono'
import { serve } from '@hono/node-server'
import { createStudioMiddleware, getStudioUrl } from 'drizzle-studio-middleware'
import * as schema from './db/schema'

// Your main app
const app = new Hono()
app.get('/health', (c) => c.json({ ok: true }))

serve({ fetch: app.fetch, port: 3000 }, () => {
  console.log('App running on http://localhost:3000')
})

// Studio on a separate port
const studioApp = await createStudioMiddleware({
  dialect: 'postgresql',
  dbUrl: process.env.DATABASE_URL!,
  schema: { public: schema },
})

serve({ fetch: studioApp.fetch, port: 4983 }, () => {
  console.log(`Studio: ${getStudioUrl()}`)
})

Supported Databases

| Dialect | Drivers | | ------------ | -------------------------- | | postgresql | postgres, pg | | mysql | mysql2 | | sqlite | Use low-level API |

How It Works

  1. This package extracts the Drizzle Studio backend logic from drizzle-kit
  2. It creates a Hono app with a single POST / endpoint that handles:
    • init — returns schema metadata, relations, dialect info
    • proxy — executes a single SQL query
    • tproxy — executes a transaction (multiple queries)
    • defaults — returns custom default values for columns
  3. The local.drizzle.studio frontend connects to this API via ?port=&host= URL parameters

License

MIT