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

@suprsend/web-sdk

v5.1.0

Published

The client side javascript library for interacting with SuprSend

Readme

SuprSend Javascript Web SDK

This is the client JavaScript SDK used to integrate SuprSend features like Webpush, Preferences in JavaScript websites like React, Next.js, Angular, Vue.js etc.

📘 Upgrading major version of SDK

We have changed the web SDK authentication from workspace key-secret to public key and JWT based authentication. This is done to improve security in frontend applications.

NPM Link | GitHub Link

Documentation

Checkout detailed documentation for this library. Refer type definitions for this library here.

Installation

# using npm
npm install @suprsend/web-sdk@latest

# using yarn
yarn add @suprsend/web-sdk@latest

Integration

1. Create Client

Create suprSendClient instance and use same instance to access all the methods of SuprSend library.

import { SuprSend } from '@suprsend/web-sdk';

export const suprSendClient = new SuprSend(publicApiKey: string);

| Params | Description | | :------------- | :----------------------------------------------------------------------------------------------------------------------------- | | publicApiKey* | This is public Key used to authenticate API calls to SuprSend. Get it in SuprSend dashboard ApiKeys -> Public Keys section |

2. Authenticate User

Authenticate user so that all the actions performed after authenticating will be w.r.t that user. This is mandatory step and need to be called before using any other method. This is usually performed after successful login and on reload of page to re-authenticate user.

const authResponse = await suprSendClient.identify(
  distinctId: any,
  userToken?: string, // only needed in production environments for security
  {
    tenantId?: string, // only needed in multi-tenant workspaces
    refreshUserToken: (oldUserToken: string, tokenPayload: Dictionary) => Promise<string>
  }
);

| Properties | Description | | :--------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | distinctId* | Unique identifier to identify a user across platform. | | userToken | Mandatory when enhanced security mode is on. This is ES256 JWT token generated in your server-side. Refer docs to create userToken. | | tenantId | Needed only when your workspace has multiple tenants. Scopes the identified user's activity to that tenant, and is inherited by events, preferences and in-app feed. Its value must match scope.tenant_id in the userToken payload, else it raises a scoping error. | | refreshUserToken | This function is called by SDK internally to get new userToken when existing token is expired or about to expire, before making any api call. The returned string is used as the new userToken. |

Returns: Promise<ApiResponse>

2.1 Check if user is authenticated

This method will check if user is authenticated i.e. distinctId is attached to SuprSend instance. To check for userToken also pass checkUserToken flag true.

suprSendClient.isIdentified(checkUserToken?: boolean): boolean

3. Reset user

This will remove user data from SuprSend instance. This is usually called on logout action.

await suprSendClient.reset();

Returns: Promise<ApiResponse>

Change active tenant

Once a tenant is set in identify, all SDK calls (events, preferences, in-app feed) are scoped to the active tenant. Use this method to switch the active tenant of an identified user. This is meant for users whose userToken scopes multiple tenants (scope.tenant_id as an array) — identify once and switch between tenants without resetting the session.

const response = suprSendClient.changeTenant(tenantId: string);

| Properties | Description | | :--------- | :-------------------------------------------------------------------------------------------------------------------------------------------------- | | tenantId* | Tenant to switch to. Used by subsequent events and newly initialized preferences and feed requests. Must be one of the tenants scoped in userToken. |

Returns: ApiResponse

Note

Already running feed instances and previously fetched preferences keep the tenant they were initialized with when changeTenant is called. Re-initialize the feed and call getPreferences again to load data for the new tenant.

Response structure

Almost all the methods in this SDK return response type Promise<ApiResponse>

interface ApiResponse {
  status: 'success' | 'error';
  statusCode?: number;
  error?: { type?: string; message?: string };
  body?: any;
}

// success response
{
  status: "success",
  body?: any,
  statusCode?: number
}

// error response
{
  status: "error",
  error: {
    type: string,
    message: string
  }
}