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

deskcord

v1.6.0

Published

The chat widget customers embed on their site. Preact + plain CSS in a shadow root, one IIFE file (`dist/deskcord.min.js`, ~51 KB gzipped) published to npm as `deskcord` and served from cdn.deskcord.chat.

Readme

Deskcord widget

The chat widget customers embed on their site. Preact + plain CSS in a shadow root, one IIFE file (dist/deskcord.min.js, ~51 KB gzipped) published to npm as deskcord and served from cdn.deskcord.chat.

Embed

<script>
  window.deskcord = {
    settings: {
      app_id: "YOUR_DISCORD_SERVER_ID",
      // theme: "auto", // "light" (default), "dark", or "auto" (follows the visitor's system)
      // locale: "fr", // widget language; defaults to the page's <html lang>
    },
  };
</script>
<script async src="https://cdn.deskcord.chat/deskcord.min.js"></script>

Colors, position, titles and the offline message come from the server's /customize-widget settings.

window.deskcord also exposes openChatbox(), closeChatbox(), identify(user), logout(), setTheme(theme) and setLocale(locale) once the script has loaded.

Theme

The widget never reads your page's colors (it lives in a shadow root). It has its own color scheme:

  • "light" (default), "dark", or "auto", which follows the visitor's system setting and updates live when it changes.
  • If your site has its own dark-mode switch, call window.deskcord.setTheme("light" | "dark" | "auto") whenever it changes. It applies immediately, no reload.

Language

The widget speaks English, French, German, Spanish, Brazilian Portuguese, Italian, Dutch, Polish, Japanese and Turkish (src/i18n/locales/). It picks, in order: settings.locale, the page's <html lang>, the visitor's browser languages, then English. Regions fall back to their language (fr-CA → French, pt-PT → Brazilian Portuguese).

  • Only the widget's own texts are translated: messages, and the titles and offline message set with /customize-widget, show as written.
  • Sites that switch language without a reload call window.deskcord.setLocale("de"). It applies immediately.
  • Adding a language: copy en.ts, translate it, register it in src/i18n/index.ts. The type checker and i18n.test.ts catch missing keys, placeholders and plural forms.

Identify logged-in users

window.deskcord.identify({
  name: "Ada",
  email: "[email protected]",
  avatarUrl: "https://example.com/ada.png", // optional, https only, shown in Discord
  userId: "42", // optional, with userHash: same conversations on every device
  userHash: "…", // HMAC-SHA256(identity secret, userId), computed on the site's server
  metadata: { plan: "pro", signupDate: "2026-01-04", mrr: 49 }, // optional, Pro servers only
});
window.deskcord.logout(); // on logout: forgets the user on this browser
  • Skips the "who should we reply to?" step. Without userId/userHash, conversations stay tied to the browser.
  • The secret comes from /identity-verification enable in Discord. It must never reach the browser.
  • To identify before the first render, pass the same object as window.deskcord.settings.user in the embed snippet.
  • Server-rendered sites should print user: null when nobody is logged in: it ends a verified session left over from a logout that didn't call logout().
  • Call it on every page load: verified sessions last 24h, and one without a token is dropped.
  • metadata gives support context in Discord (top of each new conversation, and /customer-info inside a thread). It's a flat object: values are strings (200 characters at most), numbers, booleans or null; 20 keys at most, keys of 40 characters at most, about 1 KB in all. What doesn't fit is dropped with a console warning. Each identify() replaces the previous metadata (leave it out to clear it), and logout() forgets it.
  • Metadata is not covered by userHash: the visitor can edit it in the browser, so Discord always labels it "Unverified, set by the website". Don't put secrets in it. Servers on the Free plan ignore it (nothing errors).
  • Conversations started anonymously in the browser are carried over to the user. Calling identify() with another user (or logout()) wipes the previous user's conversations from the browser.

Develop

npm install
npm run dev:mock   # mock Deskcord API on :3999 (no Discord needed)
npm run dev        # then open http://localhost:5173/?api=mock (&theme=dark|auto)

Without ?api=mock, the dev page talks to a local API on http://localhost:10001.

The mock plays the Discord side through POST localhost:3999/__mock/<action>: reply ({"text": "…"}), typing, image, edit, delete, handoff, close, reopen, offline, online, drop (cuts the live connection), auto-reply ({"on": false}), reset.

npm test           # unit tests (sync model, persistence, rich text, colors)
npm run build
npm run e2e        # drives the built widget in headless Chrome against the mock (CHROME=/path/to/chrome)

How it works

  • src/state/session.ts owns everything that talks to the server: boot, the socket, the outbox, uploads, identify/logout, read state, persistence. The UI only reads the store and calls its actions.
  • The server is the source of truth. A fetched conversation replaces the cached one; messages are matched by Discord id (src/state/model.ts), never by guessing from content.
  • Messages being sent live in an outbox, sent one at a time so they reach Discord in order, and survive a reload. Server data that may contain them waits until they're confirmed, so nothing shows twice.
  • After every reconnect (and when the tab comes back after a while) the current conversation is fetched again: events missed while offline aren't lost.
  • Unread state is a single date on the server's clock; the badge is derived from it.
  • The current page (origin + path, never the query or hash) goes with each message and socket connect (src/lib/page.ts): on Pro, the API links back to it when it emails a reply the visitor missed.
  • Data lives in localStorage under deskcord:<app_id>. Visitors from widgets before 1.0 (cookie discord-widget) are migrated on their first visit.