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

@unthread-io/portal-embed-sdk

v0.0.2

Published

SDK for embedding the Unthread customer portal in your application

Readme

@unthread-io/portal-embed-sdk

SDK for embedding the Unthread customer portal in your application. Supports vanilla JavaScript, React, and any framework.

Installation

npm install @unthread-io/portal-embed-sdk

Quick Start

React

import { UnthreadPortal } from '@unthread-io/portal-embed-sdk/react';

function SupportPage() {
  const getToken = async () => {
    const res = await fetch('/api/portal-token');
    const { jwt } = await res.json();
    return jwt;
  };

  return (
    <UnthreadPortal
      baseUrl="https://help.acme.unthread.io"
      getToken={getToken}
      onAuthenticated={() => console.log('Portal ready')}
      style={{ height: 600 }}
    />
  );
}

Using the hook for programmatic control

import { UnthreadPortal, useUnthreadPortal } from '@unthread-io/portal-embed-sdk/react';

function SupportPage() {
  const portal = useUnthreadPortal();

  return (
    <div>
      <nav>
        <button onClick={() => portal.showConversations()}>My Tickets</button>
        <button onClick={() => portal.showNewTicket()}>Submit Ticket</button>
        <button onClick={() => portal.showArticle('getting-started')}>Help</button>
      </nav>

      <UnthreadPortal baseUrl="https://help.acme.unthread.io" getToken={getToken} style={{ height: 600 }} />
    </div>
  );
}

Vanilla JavaScript

<div id="portal" style="width: 100%; height: 600px;"></div>

<script>
  // Queue calls before the script loads
  window.UnthreadPortal =
    window.UnthreadPortal ||
    function () {
      (window.UnthreadPortal.q = window.UnthreadPortal.q || []).push(arguments);
    };
  UnthreadPortal('boot', {
    baseUrl: 'https://help.acme.unthread.io',
    getToken: function () {
      return fetch('/api/portal-token')
        .then(function (res) {
          return res.json();
        })
        .then(function (data) {
          return data.jwt;
        });
    },
    container: '#portal',
  });
</script>
<script src="https://help.acme.unthread.io/embed.js" async></script>

ES Module imports

import { boot, showConversations, onAuthenticated } from '@unthread-io/portal-embed-sdk';

await boot({
  baseUrl: 'https://help.acme.unthread.io',
  getToken: async () => {
    const res = await fetch('/api/portal-token');
    const { jwt } = await res.json();
    return jwt;
  },
  container: '#portal',
});

onAuthenticated(() => {
  console.log('User is authenticated in the portal');
});

showConversations();

API Reference

Lifecycle

| Method | Description | | ------------------ | -------------------------------------------------------------------------- | | boot(options) | Initialize and render the portal | | shutdown() | Remove the portal and clean up all state | | authenticate() | Re-invoke getToken and send the result to the portal (for token refresh) | | update(userData) | Update user metadata (name, email, etc.) | | logout() | Clear the portal session |

Navigation

| Method | Description | | ------------------------------ | -------------------------------- | | navigate(path) | Navigate to any portal path | | showHome() | Navigate to the portal home page | | showConversations() | Show the ticket list | | showConversation(id) | Open a specific conversation | | showArticle(slugOrId) | Open a knowledge base article | | showNewTicket(ticketTypeId?) | Open the ticket submission form |

Events

| Method | Description | | --------------------------- | ------------------------------------------------------- | | on(event, callback) | Subscribe to an event. Returns an unsubscribe function. | | onReady(callback) | Shorthand for on('ready', callback) | | onAuthenticated(callback) | Shorthand for on('authenticated', callback) | | onError(callback) | Shorthand for on('error', callback) |

React

| Export | Description | | --------------------- | ----------------------------------------------------------------- | | <UnthreadPortal /> | Component that renders the embedded portal | | useUnthreadPortal() | Hook returning stable references to all navigation/action methods |

Boot Options

| Option | Type | Required | Description | | ----------- | --------------------------------- | -------- | --------------------------------------------- | | baseUrl | string | Yes | Portal URL | | container | string \| HTMLElement | Yes | Where to render (CSS selector or DOM element) | | getToken | () => string \| Promise<string> | Yes | Callback that returns a signed JWT |

JWT Format

Your backend signs a JWT using the embed secret key (generated in portal admin settings):

{
  "email": "[email protected]",
  "name": "Jane Doe",
  "external_id": "usr_123",
  "iat": 1709312400,
  "exp": 1709312700
}

| Field | Required | Description | | ------------- | -------- | ------------------------------------------------------------------------------------------------- | | email | Yes | User's email address. Used to identify the portal account. | | name | No | Display name shown in the portal. | | external_id | No | Your internal user ID. Reserved for future use — validated but not currently stored or processed. | | iat | Yes | Issued-at timestamp (Unix seconds). | | exp | Yes | Expiration timestamp. Max 5 minutes from iat. |

  • Algorithm: HS256
  • Max TTL: 5 minutes