Stripe.js
Official Stripe SDK for integrating payments and connect functionality in web and mobile apps.
3. Used by agents' projects
Dependency in 78 public GitHub projects set up for AI coding agents that we scanned (1.2%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
stripe.com/llms.txtFrom the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error
What Stripe.js does
Stripe maintains the TypeScript types for its official server-side Node library, but the types follow only the latest Stripe API version, and the maintainers accept that a minor upgrade can surface new type errors.
Stripe.js popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How Stripe.js is used
- Stripe.js is a dependency in 78 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (1.6% of the 4,867 JavaScript/TypeScript ones), #8 of 287 in sdks for hosted services.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 382; those are left out of every share on this page.
- The most used alternative in our scan is Stripe (JavaScript) (164 projects).
- Projects that use it most often also use Stripe (JavaScript) (85.9%), Lucide React (82.1%), clsx (73.1%).
By coding agent
Often used with
Stripe.js in practice
Strengths
As of v13 the client reattempts a failed request once if it is safe to retry. The README says idempotency keys are added where appropriate to prevent duplication. Setting <code>maxNetworkRetries</code> to <code>0</code> disables retries, but a request that fails with a closed connection (<code>ECONNRESET</code> or <code>EPIPE</code>) is still reattempted once. A higher number retries more times with exponential backoff.
As of 8.0.1, the README says Stripe maintains types for the latest API version. You import with a default import, not <code>* as Stripe</code> as with the DefinitelyTyped version. Open enum fields also accept other strings (<code>OtherString</code>), so values Stripe adds later still type-check.
<code>webhooks.constructEvent()</code> validates the signature on events Stripe sends. <code>webhooks.generateTestHeaderString</code> builds a matching header, so a test can pass a mocked signed event through the same check.
<code>timeout</code> and <code>maxNetworkRetries</code> can be set on the client or overridden on a single call. A <code>stripeAccount</code> option adds a per-request <code>Stripe-Account</code> header to any method for use with Stripe Connect.
Watch out for
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.
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 <code>// @ts-ignore stripe-version-2019-10-17</code> wherever the types differ, removed again when you upgrade.
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.
Create a customer
import Stripe from 'stripe';
const stripeClient = new Stripe('sk_test_...');
const customer = await stripeClient.customers.create({
email: 'customer@example.com',
});
console.log(customer.id);More about Stripe.js
Packages around it
- next: React framework
- lucide-react: Icon set for React
- react: UI library
- clsx: Class name joiner
- tailwind-merge: Tailwind class merger
- tailwindcss: Utility-first CSS
More in SDKs for hosted services
Alternatives
Stripe.js This page
Official SDK for integrating Stripe payments and billing into applications.
Get started
Install it.
npm install @stripe/stripe-jsRules for your agent
## 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.