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

errorbuttons

v1.0.7

Published

A lightweight frontend debugging and status-display utility that renders messages, errors, and responses directly into the browser UI as dismissible, copyable buttons.

Readme

errorbuttons

A lightweight frontend debugging and status-display utility that renders messages, errors, and responses directly into the browser UI as dismissible, copyable buttons.

errorbuttons is designed to help with:

  • frontend debugging
  • surfacing runtime errors
  • displaying API response status information
  • showing lightweight success/error notifications
  • quickly copying structured error details to the clipboard

Each message is rendered as a button that:

  1. copies its associated error data to the clipboard
  2. dismisses itself when clicked

The UI is intentionally non-invasive and sits above your application without interfering with the rest of your layout.


Features

  • Zero dependencies besides buttonizer
  • Framework agnostic
  • Works with:
    • Error
    • Response
    • ErrorEvent
    • PromiseRejectionEvent
    • strings
    • arrays
    • arbitrary values
  • Fully styleable
  • Automatically creates and removes its own container
  • Clipboard integration
  • SSR-safe
  • Multiple independent containers supported

Installation

npm install errorbuttons

Basic Usage

import setupErrorButtons from 'errorbuttons';

try {
  throw new Error('Something went wrong');
} catch (err) {
  setupErrorButtons(err);
}

Response Example

const response = await fetch('/api/test');

setupErrorButtons(response);

Promise Rejection Example

window.addEventListener('unhandledrejection', (event) => {
  setupErrorButtons(event);
});

Global Error Example

window.addEventListener('error', (event) => {
  setupErrorButtons(event);
});

Success Message Example

setupErrorButtons('Successfully saved!', {
  ok: true
});

API

setupErrorButtons(myError, options?)

Creates a new dismissible status button.

Parameters

| Parameter | Type | Description | |---|---|---| | myError | any | The value to display | | options | object | Optional configuration |


Options

General Options

| Option | Default | Description | |---|---|---| | ok | false | Forces success styling | | altMode | false | Passed directly to buttonizer | | clickEffect | false | Passed directly to buttonizer | | title | "Copy to clipboard and dismiss" | Button title attribute | | idValue | "statusbuttonerrholder" | Unique holder ID |


Style Options

Button State Styles

| Option | |---| | pressedSuccessStyles | | pressedErrStyles | | optionalSuccessStyles | | optionalErrStyles |

These are passed directly into buttonizer.


Other Style Options

| Option | Description | |---|---| | holderStyles | Styles applied to the container | | spanStyles | Styles applied to all spans | | tsStyles | Styles applied to the timestamp |


Return Value

Returns the generated button element.

const button = setupErrorButtons(error);

Clipboard Behavior

Clicking a button copies structured error information to the clipboard as JSON.

Example clipboard output:

{
  "name": "Error",
  "message": "Something exploded",
  "timestamp": "5/7/2026, 1:42:00 PM",
  "ok": false
}

Additional fields are included automatically when available:

  • status
  • statusText
  • url
  • filename
  • lineno
  • colno
  • reason
  • stack

Supported Input Types

Error

setupErrorButtons(new Error('Oops'));

Response

setupErrorButtons(response);

ErrorEvent

window.addEventListener('error', setupErrorButtons);

PromiseRejectionEvent

window.addEventListener('unhandledrejection', setupErrorButtons);

Arrays

setupErrorButtons([
  'Validation Error',
  'Username already exists'
]);

The first item becomes the title line and the second becomes the message line.


Strings

setupErrorButtons('Hello world');

Styling

The package ships with default success and error styles, but everything can be overridden.

Example:

setupErrorButtons(error, {
  holderStyles: {
    top: 'auto',
    bottom: '20px'
  },
  spanStyles: {
    color: 'red'
  }
});

SSR Compatibility

errorbuttons safely exits in non-browser environments.

const result = setupErrorButtons(error);

// null during SSR

Notes

  • This package is intentionally lightweight.
  • It is not intended to replace a full notification/toast framework.
  • Response bodies are intentionally not consumed.
  • Buttons remove themselves after being clicked.
  • Empty containers automatically clean themselves up.

License

ISC


Working Example

https://stackblitz.com/edit/vitejs-vite-ew5gmmhj?file=index.js