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

@positive-intentions/dim

v0.1.1

Published

A React-inspired functional web components framework built on native Web Components

Readme

Live Demo & Documentation | Getting Started | Demo | API Reference

GitHub stars GitHub forks GitHub issues npm License CI Staging gh-pages-build-deployment


Overview

Dim is a lightweight framework that brings React's component model and hooks to native Web Components. Write familiar functional components with hooks while leveraging the power of web standards.

Experimental: This framework is in early development and is not production-ready. It's provided for educational and experimental purposes.

Upgrading? See MIGRATION.md for breaking API changes (useStore, object attributes, useFS, crypto format). See CHANGELOG.md for release notes (created on the first publish).

Install

npm install @positive-intentions/dim

Features

  • React-like DX - Familiar hooks API (useState, useEffect, useMemo, etc.)
  • Web Standards - Built on native Web Components and Shadow DOM
  • Scoped Styling - CSS-in-JS with automatic style isolation
  • Zero runtime deps - Own template renderer; pure JS for the core (no React on the main entry)
  • Lightweight - Parts-based updates preserve focus, selection, and child state
  • State Persistence - Built-in global state management with useStore

Getting Started

Quick Example

import { html, css, define, useState, useStyle } from "@positive-intentions/dim";

// Create a component
const Counter = (props, { useState, html, css, useStyle }) => {
  const [count, setCount] = useState(0);

  useStyle(css`
    .counter {
      padding: 2rem;
      text-align: center;
    }

    button {
      background: #029cfd;
      color: white;
      border: none;
      padding: 0.5rem 1rem;
      border-radius: 4px;
      cursor: pointer;
    }
  `);

  return html`
    <div class="counter">
      <h2>Count: ${count}</h2>
      <button @click="${() => setCount(count + 1)}">Increment</button>
    </div>
  `;
};

// Register as custom element
define({ tag: "my-counter", component: Counter });

// Use it
// <my-counter></my-counter>

React interop

The main package entry does not import React, so it works with native ES modules in the browser. For the React hook that shares Dim's encrypted store:

import { useDimStore } from "@positive-intentions/dim/react";

react is an optional peer dependency required only when you use this subpath.

Core Concepts

Hooks

Dim provides React-like hooks for managing component logic:

useState - Local State Management

const [value, setValue] = useState(initialValue);

useEffect - Side Effects

useEffect(() => {
  // Effect logic
  return () => {
    // Cleanup
  };
}, [dependencies]);

useStyle - Scoped CSS

useStyle(css`
  .my-class {
    color: blue;
  }
`);

useScope - Component Composition

// Hyphenated tag keys
useScope({
  "child-component": ChildComponent,
});

// Or tagged functions after define() stamped `.tag`
define({ tag: "child-component", component: ChildComponent });
useScope({ ChildComponent });

useMemo - Memoized Values

const expensive = useMemo(() => {
  return computeExpensive(value);
}, [value]);

useRef - DOM References

const inputRef = useRef();
// Access via inputRef.current

useStore - Global State

const {
  user: [user, setUser, isLoading, , isSaving],
} = useStore(
  { user: useState({ name: "John" }) },
  { encryptionKey: "optional-secret" },
);
// isSaving is true while a debounced IndexedDB persist is in flight

Examples

Todo List

const TodoList = (props, { useState, html, css, useStyle }) => {
  const [todos, setTodos] = useState([]);
  const [input, setInput] = useState("");

  const addTodo = () => {
    if (input.trim()) {
      setTodos([
        ...todos,
        {
          id: Date.now(),
          text: input,
          done: false,
        },
      ]);
      setInput("");
    }
  };

  return html`
    <div>
      <input
        .value="${input}"
        @input="${(e) => setInput(e.target.value)}"
        @keydown="${(e) => e.key === "Enter" && addTodo()}"
      />
      <button @click="${addTodo}">Add</button>

      <ul>
        ${todos.map(
          (todo) => html`
            <li class="${todo.done ? "done" : ""}">
              <input
                type="checkbox"
                .checked="${todo.done}"
                @change="${() => toggleTodo(todo.id)}"
              />
              ${todo.text}
            </li>
          `
        )}
      </ul>
    </div>
  `;
};

Documentation

The framework includes comprehensive documentation through Storybook:

Main Sections

  1. Getting Started - Introduction and quick start guide
  2. Core Concepts - Deep dive into hooks and component architecture
  3. Tutorial - Step-by-step guide to building applications
  4. Examples - Real-world patterns and implementations
  5. API Reference - Detailed documentation for each hook

Hook Categories

  • State Management: useState, useStore
  • Effects & Lifecycle: useEffect, useRef
  • Performance: useMemo
  • Styling: useStyle
  • Composition: useScope

Visit the live documentation for interactive examples and detailed guides.

Development

Setup

# Clone the repository
git clone https://github.com/positive-intentions/dim.git

# Install dependencies
npm install

# Start Storybook dev server
npm run storybook

# Build the publishable library
npm run build:lib

# Build Storybook / federation docs site
npm run build

Project Structure

dim/
├── src/
│   ├── core/
│   │   ├── index.ts        # Public API (published as @positive-intentions/dim)
│   │   ├── dim.ts          # Compatibility shim (re-exports index)
│   │   ├── renderer/       # html/css tagged templates, parts, render()
│   │   ├── element/        # DimElement, define(), props helpers
│   │   ├── hooks/          # useState, useEffect, useMemo, useRef, useStyle, useScope
│   │   ├── store/          # useStore, crypto/storage/async managers
│   │   ├── transitions/    # view transitions + AutoTransitionHost
│   │   └── fs/             # useFS + File System Access handle persistence
│   └── stories/            # Storybook docs and demo apps
├── public/
└── README.md

Releasing

Releases are manual and Changeset-driven.

  1. In a PR that changes the public API or user-facing behavior, run npx changeset, choose patch / minor / major, and write a short summary.
  2. Merge the PR (with its changeset file) into staging.
  3. On GitHub: Actions → Publish → Run workflow (optionally enable dry_run first).
  4. The workflow versions the package, updates CHANGELOG.md, publishes @positive-intentions/dim to npm with provenance, pushes a vX.Y.Z tag, and creates a GitHub Release.

Prerequisites (one-time): create the @positive-intentions org on npm, enable Trusted Publishing for this repo’s publish.yml workflow, and create a GitHub Environment named npm (optional protection rules / required reviewers).

License

This project is licensed under the GNU General Public License v3.0 (GPL-3.0) — see the LICENSE file for details. You are free to use, modify, and distribute this software; distributed derivative works must also be licensed under GPL-3.0.

Acknowledgments

  • Inspired by React's component model and hooks
  • Built on native Web Components with Dim's own template renderer
  • Community feedback