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

lithic-embed

v0.1.0-beta.0

Published

Lithic's Embed SDK

Readme

lithic-embed

This library provides convenient access to the Lithic Embed API to easily create a modern card experience.

Installation

# npm
npm install lithic-embed

# bun
bun add lithic-embed

# pnpm
pnpm add lithic-embed

Getting Started

Create a Card Embed

import LithicEmbed, {
    EmbedMountError,
    Environment,
} from "lithic-embed";


// Using your api-key generate a session token from your backend
// See https://docs.lithic.com/reference/createcardembedsession for more information.
const sessionToken = await fetchSessionToken();
const lithicEmbed = new LithicEmbed(Environment.PRODUCTION);

const cardEmbed = lithicEmbed.card(sessionToken);

try {
    await cardEmbed.mountPan("#pan");
} catch (error) {
    if (error instanceof EmbedMountError) {
        // The iframe did not complete its render handshake in time.
    }
}

Using callbacks

You can configure callbacks to handle asynchronous notifications from the embeds.

import LithicEmbed, {
    CardDetailsRequestError,
    Environment,
    PinSubmissionError,
    EmbedUpdateState,
} from "lithic-embed";

// Using your api-key generate a session token from your backend
const sessionToken = await fetchSessionToken();
const lithicEmbed = new LithicEmbed(Environment.PRODUCTION);

// Individual callbacks are optional and are not required
const cardEmbed = lithicEmbed.card(sessionToken, {
    onCopy: (cardEmbedType: CardEmbedType, success: boolean) => {
        // Handle the whether the copy was successful or not
    },
    onUpdate: (state: EmbedUpdateState) => {
        if (state === EmbedUpdateState.EmbedRendered) {
            // Handle the embed rendered state
        }

        if (state === EmbedUpdateState.EmbedCardDetailsLoaded) {
            // Handle the embed card details loaded state
        }
    },
});

Revealing card details

By default, Lithic embeds are masked with only the pan showing the last 4 digits. To reveal the card details, call toggleMasking. toggleMasking will fetch and reveal the card details for all mounted card embeds.

await cardEmbed.mount({
    pan: { selector: "#pan" },
    cvv: { selector: "#cvv" },
    expMonth: { selector: "#expMonth" },
    expYear: { selector: "#expYear" },
});

try {
    await cardEmbed.toggleMasking();
} catch (error) {
    if (error instanceof CardDetailsRequestError) {
        // Handle a card-details request failure or SDK timeout. Locally
        // generated timeout errors do not include a code or request ID.
        console.error(error.code);
        console.error(error.requestId);
    }
}

Automatic style capture and syncing

By default, the lithic-embed SDK will sync the styles applied to the mount target.

const cardEmbed = lithicEmbed.card(sessionToken, {
    syncStyles: true // Default true. Set to false to disable auto syncing of styles.
});

// Any styles applied #pan will be applied to the embed
await cardEmbed.mountPan("#pan");

// Explicit styles take precedence over computed values
await cardEmbed.mountPan("#pan", {
    "color": "white",
    "letter-spacing": "2px"
});

Sync updates are debounced (by 100ms) so rapid changes (e.g. an animating theme) don't flood the iframe with messages.

Create a PIN-setting Embed

const pinSettingEmbed = lithicEmbed.pinSetting(sessionToken, {});
await pinSettingEmbed.mount("#pin");

try {
    await pinSettingEmbed.submit();
} catch (error) {
    if (error instanceof PinSubmissionError) {
        // Handle a PIN submission failure or SDK timeout. Locally generated
        // timeout errors do not include a code or request ID.
        console.error(error.code);
        console.error(error.requestId);
    }
}