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

@playfast/reform-db

v1.0.1

Published

Type-safe, PGlite-backed reactive SQL state for Reform — define tables once, read them as reactive Sources and write through Procedures, all typed via Kysely.

Readme

@playfast/reform-db

Type-safe, engine-neutral reactive SQL state for Reform.


Define tables once, read them reactively as Reform Sources, and write through ordinary Procedures — all with column-level type-safety inferred through Kysely. Built for on-device / local-first apps (Electron, Electrobun, browser) where the database lives next to the UI and writes are instant.

This package is the engine-neutral core: the schema/query/migration primitives and the Db driver contract. It carries queries as engine-neutral Kysely operation nodes and lets a storage engine recompile them to its own SQL dialect. Pick an engine package to actually open a database:

Install

npm install @playfast/reform-db kysely
# plus one engine:
npm install @playfast/reform-db-pglite @electric-sql/pglite   # PGlite
# or
npm install @playfast/reform-db-sqlite                        # bun:sqlite (Bun only)

effect, kysely, and @playfast/reform are peer dependencies.

Quick Start

import { Db, DbColumn, DbQuery, DbSchema, DbTable, Migration } from '@playfast/reform-db'
import { Pglite } from '@playfast/reform-db-pglite'
import { Procedure } from '@playfast/reform'
import { Layer } from 'effect'

// 1. Define tables — each column carries its SQL type + a runtime Schema.
const Environments = DbTable.make('environments', {
  columns: {
    id: DbColumn.text({ primaryKey: true }),
    name: DbColumn.text(),
    status: DbColumn.literal(['idle', 'running', 'done']),
    createdAt: DbColumn.timestamp(),
  },
  primaryKey: 'id',
})

// 2. One schema → one Kysely Database type, shared by reads AND writes.
const AppDb = DbSchema.make('app', { tables: [Environments] })

// 3. A reactive read — `yield* ActiveEnvironments` yields AsyncData<Row[]>.
const ActiveEnvironments = DbQuery.make('activeEnvironments', { output: Environments.Row })
const ActiveEnvironmentsLive = DbQuery.live(ActiveEnvironments, {
  schema: AppDb,
  inputs: [],
  build: (_inputs, db) =>
    db.selectFrom('environments').selectAll().where('status', '=', 'running').orderBy('createdAt'),
})

// 4. A write — a Procedure using Db.exec, typed against the SAME schema.
const CreateEnvironmentLive = Procedure.live(CreateEnvironment, {
  run: ({ name }) =>
    Db.exec(
      AppDb.kysely
        .insertInto('environments')
        .values({ id: ulid(), name, status: 'idle', createdAt: Date.now() }),
    ),
})

// 5. Wire an engine at the root (renderer-side, instant writes).
const DataLayer = Layer.mergeAll(ActiveEnvironmentsLive, CreateEnvironmentLive).pipe(
  Layer.provideMerge(Pglite.layer({ dataDir: 'idb://app', migrations: Migration.fromSchema(AppDb) })),
)

Use Pglite.memory() (ephemeral) — or Sqlite.memory() — in tests and @playfast/reform-proof. The Db driver is an interface, so swapping engines (or using an in-memory one for tests) changes nothing else.

There is no DbMutation primitive: a write is a side effect inside an ordinary Reform Procedure, reusing the existing mutation path rather than adding a parallel concept.

Docs

License

MIT