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

@polst-web/widget

v0.7.3

Published

Embeddable POLST widget (script/SDK mode). Zero runtime deps, Shadow DOM rendering.

Readme

@polst-web/widget

Embeddable POLST widget for script-tag / SDK embedding. Zero runtime dependencies, browser-only, style-isolated via Shadow DOM.

Install

npm install @polst-web/widget

Or load from a CDN (no install needed):

<script
  type="module"
  async
  src="https://unpkg.com/@polst-web/widget/dist/widget.esm.js"
></script>

<!-- or jsdelivr -->
<script
  type="module"
  async
  src="https://cdn.jsdelivr.net/npm/@polst-web/widget/dist/widget.esm.js"
></script>

Pin to a specific version (@polst-web/[email protected] or @0.7.0) for production stability.

Quick start

Drop a marker element anywhere on your page; the widget hydrates it on DOMContentLoaded:

<!-- single polst -->
<div data-polst="abc123def456"></div>

<!-- campaign player -->
<div data-polst-campaign="cmp_456" data-auto-advance="true"></div>

<!-- brand feed -->
<div data-polst-brand="acme" data-mode="mixed"></div>

<script
  type="module"
  async
  src="https://unpkg.com/@polst-web/widget/dist/widget.esm.js"
></script>

Each hydrated container is style-isolated inside a Shadow DOM root — host-page CSS does not leak in, widget CSS does not leak out.

Self-mounting <script> (Disqus / Intercom pattern)

A single tag both loads the widget and renders an embed:

<!-- inline: creates a sibling div immediately before the script -->
<script
  src="https://unpkg.com/@polst-web/widget/dist/widget.nomodule.js"
  data-polst="abc123def456"
></script>

<!-- targeted: mounts into an existing element -->
<div id="polst-slot"></div>
<script
  src="https://unpkg.com/@polst-web/widget/dist/widget.nomodule.js"
  data-polst="abc123def456"
  data-target="#polst-slot"
></script>

Programmatic API

For build-tooled consumers (Vite / Webpack / Next.js / etc.):

import { mount, configureOrigins } from "@polst-web/widget";

// Optional: point at a non-prod env before mounting
configureOrigins({
  apiOrigin: "https://staging-api.polst.app",
  appOrigin: "https://staging.polst.app",
});

mount(document.querySelector("#my-target"), {
  polst: "abc123def456",
  theme: "dark",
});

The full programmatic surface is exposed via window.Polst.* after the script loads (mount, configure, renderPolstCard, renderCampaignPlayer, renderBrandFeed, etc.).

Config attributes

| Attribute | Applies to | Type | Notes | | -------------------------- | ------------------- | ------- | ----- | | data-polst | polst marker | string | Polst short id | | data-polst-campaign | campaign marker | string | Campaign id | | data-polst-brand | brand marker | string | Brand slug | | data-target | script-tag only | string | CSS selector; if absent, inserts a sibling div | | data-theme | any | enum | "light", "dark", or "auto" | | data-accent | any | string | 6-char hex color override (no #) | | data-hide-title | any | boolean | Hide the widget title | | data-hide-brand | any | boolean | Hide the "by <brand>" line | | data-auto-advance | campaign | boolean | Auto-advance campaign steps after a vote | | data-mode | brand | enum | "polsts", "campaigns", or "mixed" | | data-on-vote | any | string | Name of a function on window to call on vote | | data-on-complete | campaign | string | Name of a function on window to call on completion | | data-polst-auto-observe | <html> or <body>| presence| Install a MutationObserver to hydrate late-added markers |

Boolean attributes accept "", "true", "1", "yes" (truthy) or "false", "0", "no" (falsy). Unknown callback names are logged with the [polst] prefix and silently dropped — they never throw into the host page.

SPA / dynamic content

For pages that insert markers after initial load, add data-polst-auto-observe to <html> or <body>:

<html data-polst-auto-observe>
  …
</html>

This installs a single MutationObserver that hydrates marker elements as they appear. Each hydrated container is stamped with data-polst-hydrated="1", so re-running the script is always a no-op.

Build outputs

  • dist/widget.esm.js + map — ES2020 module for modern browsers (~19 KB gzipped)
  • dist/widget.nomodule.js + map — ES5 IIFE bundle for nomodule tags (~20 KB gzipped)
  • dist/widget.d.ts — TypeScript declarations
  • dist/integrity.json — SRI hashes for the JS artifacts