@ozura/elements/react ships a context provider, hooks, and pre-built field components for both card and bank payments.
Installation
OzElements Provider
Wrap your checkout UI with<OzElements>. It creates the OzVault instance and makes it available to all children via React context. fetchWaxKey and pubKey are required.
createFetchWaxKey(url) is a built-in helper that POSTs { sessionId } to your backend URL and expects { waxKey } back. See Server SDK — Mint Wax Handler for the matching route.
You can also write the fetchWaxKey callback manually:
OzElements props
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
pubKey | string | ✅ | — | Vault pub key (client-safe) |
fetchWaxKey | (sessionId: string) => Promise<string> | ✅ | — | Callback to obtain a session wax key from your backend |
frameBaseUrl | string | — | https://elements.ozura.com | Override iframe asset URL |
fonts | FontSource[] | — | [] | Custom fonts to load in iframes |
appearance | Appearance | — | — | Global theme and variable overrides. See Styling. |
onLoadError | () => void | — | — | Called if vault fails to load |
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 |
maxTokenizeCalls | number | — | 3 | Max successful tokenize calls per wax key before proactive refresh. Must match maxTokenizeCalls in your server-side mintWaxKey call. |
children | ReactNode | ✅ | — | Your checkout UI |
useOzElements Hook
UseuseOzElements() inside any component wrapped by <OzElements> to tokenize and track readiness.
useOzElements return values
| Value | Type | Description |
|---|---|---|
createToken | (opts?: TokenizeOptions) => Promise<TokenResponse> | Tokenizes all mounted card elements |
createBankToken | (opts: BankTokenizeOptions) => Promise<BankTokenResponse> | Tokenizes mounted bank account elements |
ready | boolean | true when the vault and all mounted fields are ready. Gate your submit button on this. |
initError | Error | null | Non-null when vault initialization fails — e.g. pubKey is missing, fetchWaxKey threw, returned an empty string, or the backend was unreachable. Render a fallback UI when set. |
tokenizeCount | number | Count of successful createToken/createBankToken calls against the current wax key. Resets to 0 on every wax key refresh. Use this to display “X attempts remaining” feedback or disable the pay button while a background key refresh is completing. |
ready is a composite flag. It is true only when the vault is ready AND every field component that has been mounted has also finished loading. Do not use vault.isReady directly — that only reflects vault readiness, not field readiness.OzCard — Combined Card Component
OzCard renders card number, expiry, and CVV in a single component with built-in layout, loading skeletons, and inline error display. For maximum layout control, use the individual components instead.
OzCard props
| Prop | Type | Default | Description |
|---|---|---|---|
layout | 'default' | 'rows' | 'default' | 'default': card number on top, expiry + CVV side by side. 'rows': all three stacked vertically. |
style | ElementStyleConfig | — | Shared style applied to all three fields |
styles | { cardNumber?, expiry?, cvv? } | — | Per-field style overrides merged on top of style |
classNames | { cardNumber?, expiry?, cvv?, row? } | — | CSS class names for field wrappers and the expiry+CVV row container |
labels | { cardNumber?, expiry?, cvv? } | — | Labels rendered above each field |
labelStyle | React.CSSProperties | — | Inline style applied to all label elements |
labelClassName | string | — | CSS class applied to all label elements |
placeholders | { cardNumber?, expiry?, cvv? } | — | Placeholder overrides per field |
gap | number | string | 8 | Gap between fields (px number or any CSS value string) |
hideErrors | boolean | false | Suppress the built-in error display |
errorStyle | React.CSSProperties | — | Inline style for the error message container |
errorClassName | string | — | CSS class for the error message container |
renderError | (err: string) => ReactNode | — | Custom error renderer |
onChange | (state: OzCardState) => void | — | Fires on any field change with aggregate state |
onReady | () => void | — | Fires once all three field iframes are loaded |
onFocus | (field: 'cardNumber' | 'expiry' | 'cvv') => void | — | Fires when a field gains focus |
onBlur | (field: 'cardNumber' | 'expiry' | 'cvv') => void | — | Fires when a field loses focus |
disabled | boolean | — | Disables all inputs |
className | string | — | CSS class for the outer wrapper div |
OzCardState
Individual Card Components
UseOzCardNumber, OzExpiry, and OzCvv when you need full layout control.
The expiry component is exported as
OzExpiry, not OzExpirationDate.OzFieldProps (all individual field components)
| Prop | Type | Description |
|---|---|---|
style | ElementStyleConfig | Style overrides for this field |
placeholder | string | Placeholder text |
disabled | boolean | Disables the input |
loadTimeoutMs | number | Override the iframe load timeout for this field |
className | string | CSS class applied to the wrapper <div> |
onChange | (event: ElementChangeEvent) => void | Fired on value or state change |
onFocus | () => void | Fired when the field receives focus |
onBlur | () => void | Fired when the field loses focus |
onReady | () => void | Fired when the iframe is loaded and interactive |
onLoadError | (error: string) => void | Fired if the iframe fails to load |
OzBankCard — Combined Bank Component
OzBankCard renders account number and routing number in a single component with built-in layout, loading skeletons, and inline error display.
OzBankCard props
| Prop | Type | Default | Description |
|---|---|---|---|
style | ElementStyleConfig | — | Shared style applied to both fields |
styles | { accountNumber?, routingNumber? } | — | Per-field style overrides |
classNames | { accountNumber?, routingNumber? } | — | CSS class names for field wrappers |
labels | { accountNumber?, routingNumber? } | — | Labels rendered above each field |
labelStyle | React.CSSProperties | — | Inline style applied to all label elements |
labelClassName | string | — | CSS class applied to all label elements |
placeholders | { accountNumber?, routingNumber? } | — | Placeholder overrides per field |
gap | number | string | 8 | Gap between fields |
hideErrors | boolean | false | Suppress the built-in error display |
errorStyle | React.CSSProperties | — | Inline style for the error message container |
errorClassName | string | — | CSS class for the error message container |
renderError | (err: string) => ReactNode | — | Custom error renderer |
onChange | (state: OzBankCardState) => void | — | Fires on either field change with aggregate state |
onReady | () => void | — | Fires once both field iframes are loaded |
onFocus | (field: 'accountNumber' | 'routingNumber') => void | — | Fires when a field gains focus |
onBlur | (field: 'accountNumber' | 'routingNumber') => void | — | Fires when a field loses focus |
disabled | boolean | — | Disables all inputs |
className | string | — | CSS class for the outer wrapper div |
OzBankCardState
Individual Bank Components
UseOzBankAccountNumber and OzBankRoutingNumber for full layout control. They accept the same OzFieldProps as card fields.
Full Card Checkout Example
Next Steps
Styling
Customize field appearance with style config and global appearance.
Error Handling
Handle OzError codes and surface them to users.
Card Elements Reference
All card options, events, and methods.
Bank Elements Reference
All bank options, events, and methods.