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

@nbogie/p5.toast

v0.0.1

Published

Simple toast notification addon for p5.js v2.x

Readme

p5.toast

A minimal toast notification addon for p5.js v2.

Usage

In your sketch's index.html, add three <script> tags inside <head>, in this order:

<script src="https://cdn.jsdelivr.net/npm/p5@2/lib/p5.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@nbogie/p5.toast/dist/p5.toast.js"></script>
<script src="sketch.js"></script>

The order matters: p5 itself has to load first, then p5.toast (which plugs itself into p5), then your own sketch.

Then in sketch.js you can call toast() like any other p5 function:

function setup() {
    createCanvas(400, 400);
}

function draw() {
    background(220);
}

function mousePressed() {
    toast("hello");
}

Pinning to a specific version

The URL above always resolves to the latest published version, which means a future release could change behaviour under your sketch. To pin to a specific version, append @<version> to the package name:

<script src="https://cdn.jsdelivr.net/npm/@nbogie/[email protected]/dist/p5.toast.js"></script>

You can also pin by major or minor (e.g. @nbogie/p5.toast@0 or @nbogie/[email protected]), which lets you pick up bug-fix releases without unexpected breaking changes.

Limitations:

  • No instance mode support. Only designed for p5 global mode. (Assumes one sketch on page (or, at least, one per iframe)).
  • Currently positions toasts in top right of the document body, not the top right of the canvas.
  • No user-specified colours/styles.

Install for developers

npm install

Develop

The example sketch under example/ loads the built bundle from dist/, so a build needs to exist before the example will work.

For iterative development, run two terminals:

npm run build:watch   # rebuilds dist/ on changes to src/
npm run dev           # starts the Vite dev server for example/

Edit src/p5.toast.js; the watcher rewrites dist/, and refreshing the browser picks up the new bundle.

For a one-off check, you can instead run npm run build once and then npm run dev.

Script-tag order in the example

example/index.html loads three scripts in this order:

  1. p5.min.js (CDN) — defines window.p5.
  2. ../dist/p5.toast.js — the IIFE bundle, which calls p5.registerAddon(toastAddon) at script-eval time.
  3. ./sketch.js — defines setup / draw / etc. on window.

p5 v2 auto-starts on window.load, so by the time setup() runs the addon is registered and any methods attached to fn are available as globals.

Build

npm run build

Produces, in dist/:

  • p5.toast.js — IIFE bundle, unminified, for <script> use.
  • p5.toast.mjs — ESM bundle, for import use.