Skip to main content
The Payment Elements SDK ships as a single JavaScript bundle. Install it via npm (recommended for bundlers and frameworks) or add a <script> tag directly to your page. Both paths converge on the same CDN artifact. The npm package is a thin typed loader that injects the CDN URL at runtime.

Publishable keys

The SDK is initialized with a publishable key. The key prefix selects the API environment: Your secret key stays on your server and is used to authorize the tokenized payload the SDK returns.

Option 1: npm

Importing the default entry starts downloading the CDN bundle as a side effect. If you need to defer that download until checkout is opened, import from /pure instead:
In server-side rendered apps (Next.js, Remix, SvelteKit, etc.), call loadOverflow from client-only code such as an effect or event handler.

TypeScript types without runtime import

If you use a bare <script> tag and want editor types, add the package as a devDependency and reference the ambient types:

Latest-only policy

The npm loader always injects the floating v1 CDN URL. Pinning and Subresource Integrity are not supported through the loader. If you need pinning or SRI, use the script-tag install described below.

Option 2: script tag

Then, in your page:

Choose a versioning strategy

Every deployment of the SDK is available under two URL shapes:
  • Always serves the latest v1 release.
  • Cached at the edge for 5 minutes, so patch releases roll out within minutes.
  • You get bug fixes and non-breaking improvements without redeploying your site.
  • Cannot be used with Subresource Integrity, the file changes on each deploy.

Pinned URL (for SRI or strict change control)

  • Immutable: the artifact at a pinned version never changes.
  • Cached for one year at the edge.
  • Compatible with Subresource Integrity (see below).
  • You control the upgrade cadence by updating the version in your HTML.

Subresource Integrity (SRI)

SRI is available on pinned script-tag installs. Fetch the sidecar hash for the version you want:
The sidecar is a single ASCII line of the form sha384-<base64>. Copy it verbatim into the integrity attribute and set crossorigin="anonymous" so the browser can enforce integrity on the cross-origin script.
You can verify a local copy with openssl:

Environment hosts

For each environment, the same URL shapes exist under a different host: The host does not determine which Overflow API is called. The publishable key does: live_pub_… always routes to production, test_pub_… always routes to staging.

Preload for above-the-fold checkout

If checkout is critical to first paint, preload the bundle from <head>:
For pinned installs, mirror the integrity attribute on both tags. Do not preload on landing pages where the shopper may never reach checkout. Unused preloads waste bandwidth and log a console warning.

Content Security Policy

If your site sets a Content Security Policy, allow the CDN host in script-src and connect-src:
For staging, add https://cdn-stage.overflow.co and https://server.stage.overflow.co. If you use address autocomplete, add https://maps.googleapis.com to script-src and connect-src. See Address autocomplete.

Next steps

Quickstart

Render your first payment form.

Concepts

Elements, options, events, and theming.
Last modified on July 22, 2026