- npm
- CDN
- React
Install the core package:Then load the SDK with
loadRadiumOne(). It injects the matching CDN <script> for you, with a Subresource Integrity hash that’s baked into the npm package at publish time — you never need to look up or paste a hash yourself.loadRadiumOne()returns a shared instance for the page. Calling it again with a different key logs a warning and returns the existing instance — don’t call it more than once per key.- SSR-safe: it resolves to
nullwhen there’s nowindow(for example, during a Next.js server render). Guard fornullbefore using the result. - The load has a 10-second timeout; a failure rejects the promise. See Handle Elements failing to load for how to detect and recover from a load failure.
Never use a secret key (
r1sk_…) in browser code, mobile apps, or anywhere a shopper can inspect it. Secret keys belong on your server only.Subresource Integrity
Subresource Integrity (SRI) makes the browser refuse to run the SDK script if its contents don’t match a known hash — so a tampered script never loads.Get the hash for a CDN script tag
- Release notes — each version’s release notes include the
<script>tag with itsintegrityhash. Use these as your source of truth. - SRI manifest — for scripted version bumps, each version publishes its hashes at
https://js.radiumone.io/elements/v/sri.json(sandbox:https://js-sandbox.radiumone.io/elements/v/sri.json). The manifest is served from the same host as the script, so it can’t vouch for that host — check the hash against the release notes before you ship it.
sri.json
files["radiumone.min.js"] for your script tag. You don’t pin field.js — the card iframe checks its own hash.
Pin only a versioned path
When you move to a new version, update the path and the hash together.
Runtime attestation
Beyond SRI, the card-field iframe reports its own script hash and version on every tokenize call, and RadiumOne compares it against the expected release. If a script was tampered with in transit, tokenization fails withauth:invalid-script-hash rather than silently succeeding — see Tokenization errors. You don’t need to configure anything for this; it runs automatically.
Server-side rendering
loadRadiumOne() returns null during SSR (no window). Only call SDK methods once you have a non-null instance — the React provider and hooks already handle this for you (useRadiumOne() returns null until the SDK finishes loading in the browser).
Key validation errors
RadiumOne.init() / loadRadiumOne() throw an ElementsError if the publishable key is missing or malformed:
See Fix publishable key errors for how to detect and fix each of these.
Next steps
Accept a card payment
Mount a card field, tokenize, and charge your first test payment.
Content Security Policy
CSP directives Elements needs on your checkout page.