npm / yarn
Pre-release builds: The The
staging branch publishes automatically to the next dist-tag on every push. To test unreleased changes before they reach latest:next tag does not affect production installs — npm install @ozura/elements always resolves latest.Frame file sync: @next packages are built with NODE_ENV=staging, which bakes in the staging iframe URL (lively-hill-097170c0f.azurestaticapps.net) as frameBaseUrl. The staging Azure SWA is deployed from the same staging branch push that triggers the npm publish — so the @next SDK and the staging frame files are always in sync.@ozura/elements/react requires React 17 or later as a peer dependency. If React is not already in your project, install it first:CDN (Script Tag)
If you’re not using a bundler, load the UMD build directly from the Ozura CDN:Local Development
The CDN blockslocalhost. For local development you have two options depending on how you load the SDK:
npm install (recommended)
If your project uses a bundler (webpack, Vite, Next.js, etc.),@ozura/elements is imported directly from node_modules — no CDN involved, no workaround needed. The iframes load from elements.ozura.com at runtime, but that uses <iframe src> which is not subject to the same CORS restriction.
CDN script tag on localhost
If you want to use the CDN<script> tag during local development, you need to serve the SDK file from the same origin as your page. Install the npm package and add a single route to your local server:
<script src> in your HTML from:
/frame/tokenizer-frame.js, /frame/element-frame.js) still load from elements.ozura.com — they are fetched via <iframe src>, not fetch, so CORS does not apply.
TypeScript
The package ships with full TypeScript definitions — no@types package needed. Import types directly:
Pub Key for Local Development
Use this pub key for local and CI environments:/api/charge with a real card sale), you need valid vault API key + merchant credentials — these are production credentials. Ozura does not currently offer a separate sandbox environment for charge flows. Contact ammar@ozura.com for guidance on local charge testing.
Production frame versioning: The production npm package (
latest) loads iframe frame files from https://elements.ozura.com. These files are updated when main is deployed — all merchants receive the new frames immediately, regardless of which npm version they have installed. Ozura maintains backward compatibility in the frame ↔ SDK postMessage protocol across patch and minor releases. If you need to pin frame behavior, pass an explicit frameBaseUrl pointing to a specific deployment.Credentials
Which credentials do you need?| Goal | Required credentials |
|---|---|
| Tokenize card / bank data only (no charging) | Vault pub key + Vault API key |
| Charge cards via OzuraPay | All four credentials |
| Credential | Format | Where it lives | Required for |
|---|---|---|---|
| Vault pub key | pk_live_… or pk_prod_… | Frontend env var (safe to expose) | All integrations |
| Vault API key | key_… | Server env var only — never in browser | Minting wax keys (all integrations) |
| Pay API key | ak_… | Server env var only | OzuraPay merchants (card charging) |
| Merchant ID | ozu_… | Server env var only | OzuraPay merchants (card charging) |
Quick Initialization
OzVault.create() is the public factory method — it sets up the vault and calls your fetchWaxKey. It resolves once the wax key is obtained; you can create and mount elements immediately after. The vault is ready to tokenize once onReady fires (or vault.isReady === true).
createFetchWaxKey(url) is a built-in helper that POSTs { sessionId } to your backend and expects { waxKey } back. See Server SDK — Mint Wax Handler for the matching backend route.
createFetchWaxKey is exported from both @ozura/elements and @ozura/elements/react — they are identical re-exports of the same function. Use whichever matches your import context.
To write the fetchWaxKey callback manually:
OzVault.create() Options
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
pubKey | string | ✅ | — | Your Vault pub key |
fetchWaxKey | (sessionId: string) => Promise<string> | ✅ | — | Callback to obtain a session wax key from your backend |
frameBaseUrl | string | — | https://elements.ozura.com | Override where iframe assets are served from |
fonts | FontSource[] | — | [] | Custom web fonts to load inside iframes |
appearance | Appearance | — | — | Global theme and CSS variable overrides |
onLoadError | () => void | — | — | Called if the vault fails to load within loadTimeoutMs |
loadTimeoutMs | number | — | 10000 | Only relevant when onLoadError is set: ms to wait before calling onLoadError |
onWaxRefresh | () => void | — | — | Called when the SDK silently re-mints the wax key during a tokenization attempt |
onReady | () => void | — | — | Called once when the vault is ready (vanilla JS only; in React use useOzElements().ready) |
maxTokenizeCalls | number | — | 3 | Maximum successful createToken calls per wax key before proactive refresh. Must match maxTokenizeCalls in your server-side mintWaxKey call — see Server SDK → mintWaxKey. |
signal parameter is an AbortSignal for advanced teardown scenarios. The React OzElements provider handles this automatically — vanilla JS integrations rarely need it.
Next Steps
Card Elements
Mount card number, expiry, and CVV fields.
Bank Elements
Mount account number and routing number fields.
React
OzElements provider and pre-built components.
Server SDK
Process payments and query transactions on your backend.