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

@updatedev/js

v0.4.2

Published

Update JavaScript SDK

Readme

Update JS Library

Update is a library for seamless billing and entitlement management. It integrates with your existing tools, like Stripe and Supabase, so you can integrate without migrating away from your existing stack.

🚀 Quickstart

The easiest way to get started with Update is to use the create-update-app command:

npm create update@latest

This tool will help you choose a framework and set up a fully working Update application in seconds. Just provide a name and your API keys.

For source code examples, check out our examples repository.

✨ Features

  • Billing: Seamless payments management
  • Entitlements: Simple access control for premium features
  • Framework Support: Built-in integration for Next.js and other SSR environments

🔧 Installation

npm install @updatedev/js

🔐 Auth Integrations

🏁 Getting Started

First, you need to create an account on Update and obtain your publishable key. This key is essential for initializing the Update client in your application. Additionally, configure your preferred authentication provider to manage user sessions and access control.

⚙️ Initializing

Basic Setup

import { createClient } from '@updatedev/js';

export async function createUpdateClient() {
  return createClient(process.env.NEXT_PUBLIC_UPDATE_PUBLISHABLE_KEY!, {
    getSessionToken: async () => {
      // This must be replaced with your own logic to get your session token
      // For example, with Supabase:
      //
      // import { createSupabaseClient } from '@/utils/supabase/client'
      // ...
      // const supabase = createSupabaseClient()
      // const { data } = await supabase.auth.getSession()
      // if (data.session == null) return
      // return data.session.access_token

      // For this example, we'll just return a static token
      return 'your-session-token';
    },
    environment: process.env.NODE_ENV === 'production' ? 'live' : 'test',
  });
}

Initialization options

  • getSessionToken: A function that returns a session token for the user. This is optional, but required for most functions that require authentication.
  • environment: The environment to use for the client. Valid values are live and test.

Environment Variables (.env.local)

NEXT_PUBLIC_UPDATE_PUBLISHABLE_KEY=

🏗️ Framework Integration

Next.js Integration

Update works well with Next.js and other SSR environments. Create a utils/update directory with these files:

Client (utils/update/client.ts)

import { createClient } from '@updatedev/js';

export async function createUpdateClient() {
  return createClient(process.env.NEXT_PUBLIC_UPDATE_PUBLISHABLE_KEY!, {
    getSessionToken: async () => {
      // This must be replaced with your own logic to get your session token
      // For example, with Supabase:
      //
      // import { createSupabaseClient } from '@/utils/supabase/client'
      // ...
      // const supabase = createSupabaseClient()
      // const { data } = await supabase.auth.getSession()
      // if (data.session == null) return
      // return data.session.access_token

      // For this example, we'll just return a static token
      return 'your-session-token';
    },
    environment: process.env.NODE_ENV === 'production' ? 'live' : 'test',
  });
}

Server (utils/update/server.ts)

import { createClient } from '@updatedev/js';

export async function createUpdateClient() {
  return createClient(process.env.NEXT_PUBLIC_UPDATE_PUBLISHABLE_KEY!, {
    getSessionToken: async () => {
      // This must be replaced with your own logic to get your session token
      // For example, with Supabase:
      //
      // import { createSupabaseClient } from '@/utils/supabase/server'
      // const supabase = await createSupabaseClient()
      // const { data } = await supabase.auth.getSession()
      // if (data.session == null) return
      // return data.session.access_token

      // For this example, we'll just return a static token
      return 'your-session-token';
    },
    environment: process.env.NODE_ENV === 'production' ? 'live' : 'test',
  });
}

💳 Billing Features

Getting Products

const { data, error } = await client.billing.getProducts();

Creating a Checkout Session

const { data, error } = await client.billing.createCheckoutSession(priceId, {
  redirect_url: 'http://localhost:3000/subscription',
});

Managing Subscriptions

Get user subscriptions:

const { data } = await client.billing.getSubscriptions();

Cancel a subscription:

await client.billing.updateSubscription(id, {
  cancel_at_period_end: true,
});

Reactivate a subscription:

await client.billing.updateSubscription(id, {
  cancel_at_period_end: false,
});

🛡️ Entitlements

List Entitlements

const { data, error } = await client.entitlements.list();

Check Entitlement

const { data, error } = await client.entitlements.check('premium');

📚 Documentation

For complete documentation, visit our documentation.

💬 Support

Need help? Join our Discord community for support and discussions.

🤝 License

MIT