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

sprucex

v1.0.3

Published

Reactive HTML with a tiny ego.

Readme

SpruceX

Reactive HTML with a tiny ego.

SpruceX is a lightweight JavaScript micro-framework that blends:

  • Alpine-style declarative reactivity
  • HTMX-style network actions
  • Practical extras (stores, local persistence, lazy init, morphing, animation)

If you like shipping features straight from markup, this is your playground.

SpruceX is not complete yet and remains in active development. The 1.0.3 release line is current, so APIs, docs, and examples may continue to evolve.

Why SpruceX?

Because sometimes you want:

  • less setup than a full SPA framework
  • more power than vanilla DOM scripts
  • an API you can read directly in your HTML

SpruceX uses sx-* attributes so components stay close to the markup they control.

Quick Start (Local File)

<script src="/dist/sprucex.js"></script>

<div sx-data="{ count: 0 }">
  <button sx-on:click="count++">+1</button>
  <span sx-text="count"></span>
</div>

SpruceX auto-initializes on DOMContentLoaded.

Get SpruceX

SpruceX ships in two formats:

  • browser bundle: public/dist/sprucex.js or public/dist/sprucex.min.js
  • package entrypoints: lib/sprucex.mjs, lib/sprucex.cjs, and lib/sprucex.d.ts

For script-tag usage, include the browser bundle and use the global SpruceX object. For package usage, import the built library entrypoint exposed by package.json.

npm install sprucex
import SpruceX from "sprucex";
// Named imports are also supported: import { SpruceX } from "sprucex";

Basic API

<script src="/dist/sprucex.js"></script>
<script>
  SpruceX.store("cart", { items: [] }, { persist: true });
  SpruceX.init(); // optional (auto-init runs by default)
</script>

Handy expression globals:

  • $event
  • $refs
  • $store(name)
  • $emit(name, detail)
  • $index (inside sx-for)

sx-for recommendations

  • Use sx-key on template[sx-for] when list items can reorder.
  • Avoid index-based keys for sortable/reorderable lists.
  • Nested sx-data roots inside sx-for rows are supported for row-local UI state.
  • Duplicate keys in a loop are invalid and can cause unstable row reuse.

Integration Plugins

SpruceX supports integration plugins through SpruceX.integration(...).

<script>
  SpruceX.integration("my-widget", {
    scan(component, el) {
      const expr = el.getAttribute("sx-my-widget");
      if (!expr) return;
      if (!component._myWidgetBindings) component._myWidgetBindings = [];
      component._myWidgetBindings.push({ el, expr });
    },
    update(component) {
      const bindings = component._myWidgetBindings || [];
      bindings.forEach(({ el, expr }) => {
        // evaluate through component scope
        const value = component.evaluateExpressionOrLiteral(expr);
        el.textContent = String(value ?? "");
      });
    },
    teardown(component) {
      component._myWidgetBindings = [];
    },
  });
</script>

Plugin hooks:

  • setup(component) optional one-time setup per component instance
  • scan(component, el) collect integration bindings while SpruceX scans markup
  • update(component) run on initial render and reactive updates
  • teardown(component) cleanup on refresh/destroy

Development

Requirements

  • Bun (used for library builds)
  • Node.js (for Astro dev/build workflow)

Scripts

# install deps
bun install

# docs/dev site
bun run dev

# build library + Astro site
bun run build

# preview production build
bun run preview

# watch only library bundle
bun run dev:lib

# runtime, TypeScript consumers, and packed-package checks
bun run test

# install browsers once, then run the complete release checks
bunx playwright install chromium firefox webkit
bun run check:release

CI runs the release checks on pushes and pull requests. npm pack rebuilds and validates the package; npm publish also requires the production site build and browser tests to pass. Contributors need Node.js 22.12+ and Bun 1.2.13+.

Project Structure

src/
  core/          # component internals
  store/         # global store implementation
  utils/         # helpers, eval, dom, morph, animations
  pages/         # Astro docs/examples pages
  fragments/     # example markup used in docs
public/
  dist/          # browser bundles (sprucex.js, sprucex.min.js)
  llm-docs.md    # full directive/API docs

Docs

  • Interactive docs/examples live in the Astro site (bun run dev)
  • Extended reference: public/llm-docs.md
  • Machine-readable reference: public/LLM.txt
  • Release notes: CHANGELOG.md

Contributing

PRs and issues are welcome.

Good starter contributions:

  • examples that cover edge cases
  • bugfixes with small reproducible demos
  • docs improvements for directive behavior

If you open a PR, please include:

  • what changed
  • why it changed
  • how you tested it

Status

Current release target in package.json: 1.0.3

SpruceX is still in active development and is not complete yet. Use the docs site, public/LLM.txt, and CHANGELOG.md as the current source of truth for what is implemented.

License

MIT. See LICENSE.