stripe-js

The official ES/CommonJS loader for Stripe.js and Stripe Elements

SDK
npm
v9.13.0
753stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
88/100Excellent
Development Activity88
Maintenance92
Community84
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
89/100Excellent
Architecture85
Code Quality88
Innovation92
Learning Curve90

@stripe/stripe-js is the official loading wrapper that lets you import Stripe.js as an ES module or CommonJS module instead of relying on a hand-written script tag. It exposes a single loadStripe helper that returns a promise resolving to a fully initialized Stripe object, handling script injection, version pinning, and PCI-compliant loading from js.stripe.com for you.

Because Stripe.js must be served directly from Stripe’s domain to stay PCI compliant, this package never bundles the payment library itself — it wraps the global Stripe constructor and ships TypeScript definitions that track the latest Stripe API. That makes it the standard entry point for adding Stripe Elements, Payment Intents, and advanced fraud detection to any modern JavaScript or TypeScript web application.

What You Get

  • A promise-based loadStripe(publishableKey) helper that resolves to an initialized Stripe object
  • Automatic insertion of the Stripe.js script tag from js.stripe.com, with reuse of any existing tag
  • A side-effect-free @stripe/stripe-js/pure entry point for deferred loading and load-parameter control
  • Bundled TypeScript definitions that track the latest Stripe API and Elements
  • Server-side safety — loadStripe resolves to null when called outside the browser

Common Use Cases

  • Mounting Stripe Elements to collect card and payment details in a React, Vue, or vanilla web app
  • Confirming Payment Intents and Setup Intents on the client during checkout
  • Enabling Stripe’s advanced fraud detection by loading Stripe.js on every page
  • Deferring Stripe.js loading until checkout to minimize third-party requests on other pages

Under The Hood

Architecture

The package is a small, single-purpose loader split across three source files in src/. shared.ts holds the core: loadScript guards a module-level stripePromise singleton so Stripe.js is fetched at most once, calling findScript/injectScript to reuse or create a <script src="https://js.stripe.com/..."> tag and wiring load/error listeners that resolve to window.Stripe; initStripe then validates the publishable key, compares the runtime release train, and calls _registerWrapper for telemetry. index.ts is the default entry that eagerly kicks off loadScript on import (after a microtask) so the tag lands early, while pure.ts is the deferred variant that only loads on the first loadStripe call and adds setLoadParameters.

Tech Stack

Written almost entirely in TypeScript (~92%), the package has zero runtime dependencies and is built with Rollup (rollup.config.js) plus Babel to emit both CommonJS (lib/index.js) and ES module (lib/index.mjs) bundles, with @rollup/plugin-replace inlining the package version into _VERSION. Type declarations live under types/ and are copied into the published output. Tooling includes ESLint, Prettier, and @arethetypeswrong/cli for package-export correctness, targeting Node >= 12.16 and TypeScript >= 3.1.

Code Quality

Code quality is high for a library this size. Each source module has a colocated Jest test (index.test.ts, pure.test.ts, shared.test.ts) and the test script chains unit tests, type-snapshot tests, are-the-types-wrong checks, and tsc typechecking. Error handling is explicit and user-facing — clear thrown Error messages for invalid keys and load parameters, a cause-wrapped ‘Failed to load Stripe.js’ rejection, and cache reset on failure so a retry can re-inject the script. Naming is consistent and the public surface is deliberately tiny.

API Design

The developer experience is excellent: the entire public API is essentially loadStripe(publishableKey) returning a typed promise, which removes nearly all boilerplate compared with hand-managing a script tag. The /pure entry point and setLoadParameters give an escape hatch for deferred loading and fraud-signal control without complicating the common path, and isomorphic safety (resolving to null on the server) means the same import works in SSR. Documentation in the README is thorough, with runnable examples and an examples/ directory.

Used by 44 apps in this directory

TypeScript
76%
AGPL 3.0

Abby

Developer Tools · Product Management

167

Statically typed feature flags, remote config, and A/B testing with framework-native SDKs for TypeScript teams.

View details
30
Repo Health
70
Technical
63
Dependency
Built with
TypeScript76%
MDX18%
Updated 1 years ago
TypeScript
51%
MIT

Anarlog

Note Taking · AI Assistants · Productivity

9,087

Anarlog is an open-source, local-first AI meeting notetaker that records, transcribes, and summarizes meetings entirely on your device — no cloud lock-in, no mandatory account, and every note saved as a plain markdown file you own forever.

View details
86
Repo Health
77
Technical
69
Dependency
Built with
TypeScript51%
Rust38%
Updated today
TypeScript
96%
Other

Cal.diy

Scheduling

47,796

The 100% MIT-licensed, community-driven scheduling platform — self-host your own booking infrastructure with no enterprise strings attached.

View details
93
Repo Health
86
Technical
66
Dependency
Built with
TypeScript96%
Updated 1 weeks ago
TypeScript
55%
Other

Cap

Team Chat · Video Conferencing

20,986

Open source Loom alternative with GPU-accelerated recording, instant share links, AI summaries, and full self-hosting via Docker Compose.

View details
89
Repo Health
81
Technical
65
Dependency
Built with
TypeScript55%
Rust40%
Updated yesterday
Java
48%
Apache 2.0

ClearFlask

Product Management · Community

448

Open-source feedback management and roadmap tool that lets product teams collect, prioritize, and respond to user input — with AI-powered summarization and full self-hosting control.

View details
83
Repo Health
73
Technical
63
Dependency
Built with
Java48%
TypeScript47%
Updated 2 weeks ago
TypeScript
45%
Other

Convex Backend

Developer Tools · Databases

12,394

Open-source reactive database that lets developers build live-updating apps with pure TypeScript, strong consistency, and real-time subscriptions—no separate API layer required.

View details
88
Repo Health
82
Technical
70
Dependency
Built with
TypeScript45%
Rust43%
Updated today
Go
72%
Other

Convoy

Developer Tools · Devops

2,858

Convoy is an open-source, cloud-native webhooks gateway that ingests events over HTTP or straight from Kafka, SQS, Google Pub/Sub, and RabbitMQ, then reliably delivers them to subscriber endpoints with signed payloads, automatic retries, circuit breaking, and JavaScript-based transformations.

View details
89
Repo Health
81
Technical
68
Dependency
Built with
Go72%
TypeScript14%
HTML13%
Updated yesterday
TypeScript
93%
AGPL 3.0

CourseLit

Ecommerce · Blogging

1,255

Open-source, self-hosted LMS for selling online courses, digital downloads, and building communities on your own branded website.

View details
78
Repo Health
74
Technical
72
Dependency
Built with
TypeScript93%
Updated 4 weeks ago
PHP
48%
AGPL 3.0

Crater

Invoicing Finance

8,341

Open source invoicing and billing platform for freelancers and small businesses — create estimates, track expenses, accept Stripe payments, and run recurring invoices from your own server.

View details
54
Repo Health
68
Technical
69
Dependency
Built with
PHP48%
Vue40%
Updated 2 years ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search