# Stripe.js — card for AI agents

Official Stripe SDK for integrating payments and connect functionality in web and mobile apps.

Category: SDKs for hosted services · npm package `@stripe/stripe-js` · latest version 10.2.0 (checked 2026-11-01)
Install: `npm install @stripe/stripe-js`
License: MIT (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Rules for AI agents (paste into AGENTS.md or CLAUDE.md)

## Stripe (stripe-node)
- Use `stripe` only in server-side code with the secret key; use Stripe.js to collect payment details in the browser.
- Import with `import Stripe from 'stripe'` (a default import, not `* as Stripe`) and instantiate with `new Stripe(...)`.
- If the file that creates the client can be imported while `STRIPE_SECRET_KEY` is absent (for instance during a build step), create the client lazily in a getter or pass a placeholder key.
- In webhook handlers, pass the raw request body to `webhooks.constructEvent()`, never a parsed JSON body; use `webhooks.generateTestHeaderString` to mock signed events in tests.
- Expandable fields are typed `string | Foo`; cast them (e.g. `as Stripe.Customer`) or use a helper that returns the `id`.
- Do not set `protocol: 'http'`; the README strongly discourages it, even in local testing, because credentials can be sent over an insecure channel.
- After a minor upgrade, fix new TypeScript errors with additional type guards.

## Docs written for agents
- [llms.txt (index of the docs)](https://stripe.com/llms.txt)

## What it is
- `stripe` (stripe-node) is Stripe's Node.js library for the Stripe API. The GitHub repository was created on 2011-09-28 and is MIT licensed. The README says it gives access to the Stripe API "from applications written in server-side JavaScript". For collecting card and customer details in the browser, it points to a separate library, Stripe.js.
- You configure the client with your account's secret key from the Stripe Dashboard. Then you call resource methods such as `stripeClient.customers.create()`. The README shows both an ES module import and a CommonJS `require`. It says every method returns a chainable promise. As of 11.16.0 there is a `deno` export target, imported as `npm:stripe`. The README says Stripe currently supports all LTS versions of Node.js 20+.
- The README's examples create customers, invoice items and invoices, retrieve payment intents with `expand`, and list balance transactions for a connected account. It also covers checking signatures on incoming webhook events. Most of the remaining text is about client options and how the TypeScript types are versioned.

## Caveats
- Server only: The library is configured with a secret key and is meant for server-side JavaScript. For collecting payment details in the browser, the README sends you to Stripe.js.
- Types match only the latest API version: If your account uses an older API version, the types may not match the responses you get back. The README encourages upgrading your API version. If you cannot upgrade, it suggests a comment like `// @ts-ignore stripe-version-2019-10-17` wherever the types differ, removed again when you upgrade.
- Minor upgrades can break your type check: Some API changes weaken the existing types but cannot break anything at runtime. The maintainers write that they "do NOT consider such changes to be breaking". A minor version bump can therefore bring TypeScript errors that need extra type guards.
- Missing API key errors during builds: From `v17.x.x`, the README warns that an error about a missing API key is likely caused by importing the file that creates the client while the key is not present, for instance during a build step. It suggests creating the client lazily or passing a placeholder key.
- Webhooks need the raw body: `constructEvent()` will not work with a request body that has already been parsed as JSON. You must pass the body exactly as Stripe sent it.

## Numbers (AgentGid data)
- Gid Score: 62.2 (#851 of all tools, 32 of 287 in its category)
- Used in 78 public projects set up for AI coding agents (1.2%)
- Downloads last week: 20,851,826 (as of 2026-11-24), +43.9% over 4 weeks
- GitHub stars: 756 (as of 2026-11-24)
- Last push: 2026-11-20

## Often used with
Stripe (JavaScript) 85.9%, Lucide React 82.1%, clsx 73.1%, Tailwind Merge 71.8%, Class Variance Authority 67.9%, React 93.6%

## Checked alternatives (same job)
- Stripe (JavaScript): https://agentgid.com/tools/stripe-node/agent.md

## Links
- AgentGid page: https://agentgid.com/tools/stripe-npm/
- Homepage: https://stripe.com/docs/js
- Repository: https://github.com/stripe/stripe-js
- Source: https://github.com/stripe/stripe-node#readme
- Source: https://github.com/stripe/stripe-node
- Source: https://github.com/stripe/stripe-node/releases

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
