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

@8lines/gauntlet-widget

v0.1.8

Published

Typed, SSR-safe commands and page-subject types for embedding the Gauntlet widget in a web application.

Readme

Gauntlet widget

@8lines/gauntlet-widget provides typed, SSR-safe command functions and types for embedding the Gauntlet widget in a web application. The widget is a floating panel that displays operations matching the current page, with inputs prefilled from page context (URL parameters, page state, or explicit subject data).

Quick start: inline snippet

For a single-file HTML page or simple setup:

<script>
  window.Gauntlet ||= function () { (Gauntlet.q ||= []).push(arguments); };
  Gauntlet("boot", {
    target: "shop",
    routes: [
      { pattern: "/orders/:orderId", subject: "order" },
      { pattern: "/customers/:customerId/orders/:orderId", subjects: { customer: ["customerId"], order: ["orderId"] } },
    ],
  });
</script>
<script src="https://gauntlet.internal/widget/loader.js" async></script>

NPM usage

Install the package:

npm install @8lines/gauntlet-widget

Load the widget and configure it:

import { boot, loadGauntletWidget } from '@8lines/gauntlet-widget';

// Inject the loader script once
loadGauntletWidget('https://gauntlet.internal');

// Boot the widget with your target and URL-to-subject mappings
boot({
  target: 'shop',
  routes: [
    { pattern: '/orders/:orderId', subject: 'order' },
    { pattern: '/customers/:customerId', subject: 'customer' },
  ],
});

Page subjects and context

Define page subjects manually:

import { setSubject, removeSubject } from '@8lines/gauntlet-widget';

// On an order page, set the order ID
setSubject('order', { orderId: '12345' });

// Remove it when the page changes
removeSubject('order');

React hook example

Use a hook to keep page context in sync:

import { useEffect } from 'react';
import { setSubject, removeSubject } from '@8lines/gauntlet-widget';

export function OrderPage({ orderId }: { orderId: string }) {
  // Depend on the primitive value, not on a values object that is new on every render.
  useEffect(() => {
    setSubject('order', { orderId });
    return () => removeSubject('order');
  }, [orderId]);
  // ...
}

Security and production gating

Include the widget only in non-production builds. Gate it with an environment flag:

if (process.env.NODE_ENV !== 'production') {
  loadGauntletWidget('https://gauntlet.internal');
  boot({ target: 'shop', routes: [...] });
}

The widget is unusable without proper configuration; see Origin allowlist below.

Origin allowlist

The page origin must be explicitly configured in Gauntlet. Enable the widget and add the application's origin to the target configuration:

widget:
  enabled: true
targets:
  - id: shop
    label: Shop
    adapterUrl: http://shop-dev:8080
    expectedEnvironment: { name: dev, kind: development }
    widget:
      origins:
        - https://shop.dev.example
        - https://shop.staging.example

Without this configuration, the widget will not function. This prevents unauthorized origins from accessing the Gauntlet instance.

API reference

| Function | Purpose | | --- | --- | | loadGauntletWidget(gauntletUrl) | Inject the loader script once (idempotent) | | boot(options) | Initialize the widget with target and route rules | | setSubject(type, values) | Set or update page context for a subject type | | removeSubject(type) | Remove page context for a subject type | | open() | Programmatically open the widget panel | | close() | Close the widget panel | | shutdown() | Disable the widget |

SSR safety

All functions are SSR-safe. When window is not available (Node.js, early SSR phases), commands silently become no-ops. No errors or warnings are emitted.


Documentation index