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

smart-widget-builder

v1.0.10

Published

A package for NodeJS to build Nostr Smart Widgets

Downloads

43

Readme

Smart Widget (SW) - Nostr Integration Library

A JavaScript library for creating and managing Smart Widgets on the Nostr protocol.

Installation

npm install smart-widget-builder

Features

  • Create and publish Smart Widgets to Nostr relays
  • Flexible relay configuration
  • Event signing and publishing
  • Nostr event searching capabilities

Quick start

const { SW, Image, Input, Button, SWComponentsSet } = require('smart-widget-builder');

// Initialize Smart Widget
const sw = new SW("basic", ['wss://relay.example.com']);

// Create components
const components = new SWComponentsSet([
  new Image('https://example.com/image.jpg'),
  new Input('Enter text here'),
  new Button(1, 'Click Me', 'redirect', 'https://example.com')
]);

// Connect and publish
async function publishWidget() {
  await sw.init();
  const result = await sw.publish(components, 'My Widget');
  console.log(result);
}

Classes

SW

Main Smart Widget class for managing Nostr connections and publications

  • Smart widget types: basic, action, tool
    • basic a smart widget with multiple components
    • action a smart widget with an image and a button of type app, this should open the url in a form of an iframe (the iframe should return nothing)
    • tool a smart widget with an image and a button of type app, this should open the url in a form of an iframe (the iframe should return data)
  • constructor(type, relaySet, secretKey) - A type pf basic is the default and a preset relays list and a randomly generated secret key will be used if the construction params are left empty
  • init() - Connect to relays
  • publish(components, title, identifier, timeout) - Publish a widget
  • signEvent(components, title, identifier) - Sign a widget event
  • searchNostr(filter) - Search Nostr events

Components

  • Icon(url) - Icon component, it is recommended with widgets of action and tool types
  • Image(url) - Image component
  • Input(label) - Input field component
  • Button(index, label, type, url) - Button component
    • Button types: redirect, nostr, zap, post, app
    • redirect a URL redirect
    • nostr a nostr schema URL (ie: nostr:npub.. , nevent1..)
    • zap a lightning address or a lightning invoice to proceeding for zapping
    • post a POST request to an endpoint that returns a smart widget event
    • app an internally opened URL
  • SWComponentsSet(components, SW_INSTANCE) - Component collection

Configuration (optional if used in NodeJS)

Create a .env file for the secret key, this will be used as a fallback if the SW() constructor was not provided with one to sign and publish event

SECRET_KEY=your-hex-secret-key