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

smol.js

v0.1.0

Published

Minimal Web Component library with zero dependencies

Downloads

14

Readme

smol.js

Minimal Web Component library with zero dependencies

Features

  • Zero dependencies - Only ~3KB gzipped
  • Standards-based - Uses native Web Components
  • TypeScript-first - Full type safety
  • Reactivity - Fine-grained signals and state
  • SSR ready - Server-side rendering support
  • Framework-agnostic - Works with anything

Installation

npm install smol.js

Quick Start

Basic Component

import { smolComponent, html, smolSignal } from 'smol.js';

smolComponent({
  tag: 'my-counter',
  
  // Scoped CSS
  styles: css`
    button { padding: 0.5rem; }
  `,
  
  // Component Logic
  connected() {
    this.count = smolSignal(0);
  },
  
  // Template with automated reactivity
  template(ctx) {
    const count = this.count.value;
    
    return html`
      <button @click=${() => this.count.value++}>
        Count: ${count}
      </button>
    `;
  }
});

Core Concepts

Components (smolComponent)

Creates a standard native Web Component.

smolComponent({
  tag: 'user-card',
  
  // Define attributes to watch for changes
  observedAttributes: ['username'],
  
  // Lifecycle methods
  connected() { console.log('Mounted'); },
  disconnected() { console.log('Unmounted'); },
  
  // React to attribute changes
  attributeChanged(name, oldVal, newVal) {
    // ...
  },
  
  // Render template
  template(ctx) {
    return html`<div>Hello ${ctx.element.getAttribute('username')}</div>`;
  }
});

Reactivity (smolSignal, computed, effect)

Fine-grained reactivity system.

// Create a signal
const count = smolSignal(0);

// Create a computed value (updates automatically)
const double = computed(() => count.value * 2);

// Run a side effect when signals change
effect(() => {
  console.log(`Count is ${count.value}, double is ${double.value}`);
});

count.value++; // Logs: "Count is 1, double is 2"

Services (smolService)

Singleton services for global state and logic.

// Define service
export const authService = smolService({
  name: 'auth',
  factory: () => {
    const user = smolSignal(null);
    return {
      user,
      login: (name) => user.value = name
    };
  }
});

// Use in component
import { authService } from './auth.service';

smolComponent({
  // ...
  template(ctx) {
    const user = authService.user.value;
    return html`
      <div>User: ${user}</div>
      <button @click=${() => authService.login('Alice')}>Login</button>
    `;
  }
});

Templates

External Templates (.html?smol)

You can separate your HTML and CSS into files using the Vite plugin.

vite.config.ts:

import { smolTemplatePlugin } from 'smol.js/vite';
export default {
  plugins: [smolTemplatePlugin()]
};

my-cmp.ts:

import template from './my-cmp.html?smol';
import styles from './my-cmp.css?inline';

smolComponent({
  tag: 'my-cmp',
  styles,
  template(ctx) {
    // Variables used in HTML must be available in context or locals
    return template(html, this); 
  }
});

my-cmp.html:

<div>
  <!-- 'count' refers to this.count from the component instance -->
  Count: ${count.value}
</div>

Hydration

For Client-Side Hydration of SSR content:

main.ts:

// Initializes hydration for all components
import 'smol.js/src/hydrate-client'; 

Or manually:

import { hydrateAll } from 'smol.js';

document.addEventListener('DOMContentLoaded', () => {
  hydrateAll();
});

API Reference

html

Tagged template literal for defining HTML structure.

css

Tagged template literal for defining styles.

smolState(obj)

Creates a deeply reactive object proxy.

inject(service)

Retrieves a service instance (mostly used internally or for testing).

License

MIT