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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@salable/js

v5.0.0

Published

A set of functions to simplify building Salable applications on the client.

Readme

A set of functions to simplify building Salable applications on the client.

Installation

# npm
npm install @salable/js

# pnpm
pnpm add @salable/js

# yarn
yarn add @salable/js

Functions

The library exports both ECMAScript Modules (ESM) and CommonJS (CJS) builds.

import salableJs from '@salable/js'
// or
const salableJs = require('@salable/js')

For convenience, the functions documented are also added to the browser's window object as part of the salable object. So, getGrantee can be accessed via window.salable.getGrantee.

getGrantee({ apiKey: string, productUuid: string, granteeId?: string })

Returns the features the provided grantee has access to.

Also returns a hasFeature utility function that simplifies feature checking.

Example

import { getGrantee } from '@salable/js'

const { features, hasFeature } = await getGrantee({
  apiKey: 'your-api-key',
  productUuid: 'your-product-uuid',
  granteeId: 'your-users-grantee-id',
})

if (hasFeature('edit')) {
  console.log('Grantee has access to the edit feature!')
}

getProduct({ apiKey: string, productUuid: string, withDeprecated?: boolean})

Returns useful data about the current product. Can be used for many things including the creation of custom pricing tables.

By default, plans and features that are marked as DEPRECATED will be excluded from the response. If you would like these returned, you can pass in an optional options object with { withDeprecated: true }.

Example

import { getProduct } from '@salable/js'

const { name, plans } = await getProduct({
  apiKey: 'your-api-key',
  productUuid: 'your-product-uuid',
  withDeprecated: true,
})

getCheckoutLink({ apiKey: string, planUuid: string, successUrl: string, cancelUrl: string, granteeId: string, owner: string })

Returns a checkout link for the specified planUuid.

Example

import { getCheckoutLink } from '@salable/js'

const checkoutLink = await getCheckoutLink({
  planUuid: 'your-plan-uuid',
  apiKey: 'your-api-key',
  successUrl: 'https://your.apps/success',
  cancelUrl: 'https://your.apps/cancel',
  granteeId: 'your-users-id',
  owner: 'your-users-id',
  checkoutEmail: '', // optional, pre-fills email field in Stripe checkout
  quantity: 5, // optional, the number of seats purchased on checkout (if using per-seat plan, default is minimum number set on plan)
  currency: 'EUR', // optional, defaults to the product's default currency in Salable
})

createScope({ apiKey: string, productUuid: string })

Creates scoped versions of all other functions exposed by this package where the productUuid and apiKey are already provided. This allows you to pass these values in one time, rather than with each call if that's what you'd prefer.

This function isn't available on the window.salable object in the browser.

Example

import { createScope } from '@salable/js'

const { getGrantee, getProduct } = createScope({
  apiKey: 'your-api-key',
  productUuid: 'your-product-uuid',
})

// This function now only takes the `granteeId`, the other values are already
// passed in by the `createScope` call.
const grantee = await getGrantee({ granteeId: 'the-users-grantee-id' })