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

spark-html

v0.12.0

Published

Get your spark back. HTML that reacts!.

Readme

⚡ spark-html

Single-file HTML components with built-in reactivity. No compiler, no virtual DOM, no build step.

Install

npm install spark-html

Quick start

A component is a plain .html file — markup, script, style:

<!-- components/welcome.html -->
<h1>Welcome {name}</h1>

<script>
  let name = 'John Doe';
</script>

<style>
  h1 { color: rebeccapurple; }
</style>

Import it in your page and mount:

<!-- index.html -->
<body>
  <div import="components/welcome"></div>
  <script type="module">
    import { mount } from 'spark-html';
    mount();
  </script>
</body>

With Vite

// vite.config.js
import { defineConfig } from 'vite';
import spark from 'spark-html/vite';

export default defineConfig({ plugins: [spark()] });

The plugin serves component fragments raw and full-reloads when they change.

API

Template syntax

| Feature | Syntax | |---------------------|--------------------------------------------------| | Text binding | <p>Hello {name}</p> | | Expressions | <p>{price * qty}</p> {ok ? 'x' : 'y'} | | Events | <button onclick={add}> | | Dynamic attributes | <button :disabled="count >= 10"> | | Attribute interp | <input value="{input}"> | | Loops | <template each="todo in todos">…</template> | | Loops with index | <template each="todo, i in todos">…</template> | | Scoped styles | <style> auto-scoped to the component | | Global styles | :global(body) { … } escapes scoping | | Two-way binding | <input bind:value="draft"> / bind:checked | | Reactive statements | $: doubled = count * 2 — re-runs on change | | Conditional blocks | <template if="show">…</template> | | Lifecycle | onMount(fn) builtin; return a fn for cleanup | | Escape hatch | spark-ignore attribute — subtree never patched |

Props

Attributes on the import placeholder become props. export let in the component declares which variables are props, with defaults:

<div import="components/profile" name="Ada Lovelace" age="36" admin></div>
<!-- components/profile.html -->
<h2>{name}{admin ? ' (admin)' : ''}, {age}</h2>
<script>
  export let name = 'Anonymous';
  export let age = 0;        // "36" is coerced to number 36
  export let admin = false;  // bare attribute → true
</script>

Coercion: numbers, true/false, null, and JSON (items='["a","b"]') are parsed; everything else stays a string. Variables declared with plain let are private — outside attributes cannot override them.

Stores (shared state)

Create named stores in app code; subscribe from any component with the useStore builtin. Every subscriber re-patches when the store changes:

// main.js
import { mount, store } from 'spark-html';
store('cart', { items: [], total: 0 });
mount();
<!-- any component -->
<p>{cart.items.length} items — ${cart.total}</p>
<script>
  const cart = useStore('cart');
  function add() {
    cart.items = [...cart.items, 'thing'];
    cart.total = cart.total + 4;
  }
</script>

JavaScript

import { mount, component, store } from 'spark-html';

await mount();          // whole document
await mount('#app');    // a subtree

// register a component from a string (no file needed) — great for tests
component('hello', `
  <h1>Hi {who}</h1>
  <script>let who = 'tester';<\/script>
`);

How it works

  1. mount() finds <div import="..."> placeholders and fetches each file.
  2. Script and style are extracted from the raw text before the markup touches innerHTML (browsers strip script tags injected that way).
  3. The script runs inside a Proxy scope; every assignment re-patches only that component's DOM.
  4. Styles are auto-scoped via a [name="component"] prefix.

Limits

  • One reactive scope per component (top-level let/function)
  • Block-scoped let/const inside functions hoist to component scope
  • Loop bodies are read-only snapshots; replace the array to update