Documentation Index
Fetch the complete documentation index at: https://docs.ozura.com/llms.txt
Use this file to discover all available pages before exploring further.
@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. pubKey and a session option are required.
sessionUrl is the simplest option — just pass your session endpoint path. See Server SDK — Session route for the matching backend route.
For custom headers or auth tokens, use getSessionKey instead:
OzElements props
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
pubKey | string | ✅ | — | Vault pub key (client-safe) |
sessionUrl | string | ✅ ¹ | — | URL of your session endpoint — simplest option |
getSessionKey | (sessionId: string) => Promise<string> | ✅ ¹ | — | Custom callback for session key retrieval (custom headers, auth, etc.) |
fetchWaxKey | (sessionId: string) => Promise<string> | ✅ ¹ | — | Deprecated — use sessionUrl or getSessionKey |
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 |
onSessionRefresh | () => void | — | — | Called when the SDK silently refreshes the session during a tokenization attempt |
onReady | () => void | — | — | Called once when the vault is ready |
sessionLimit | number | null | — | 3 | Max successful tokenize calls per session before auto-refresh. Pass null to remove the cap. Must match sessionLimit in your server-side createSession call. |
debug | boolean | — | false | Enables [OzVault]-prefixed console.log output at every lifecycle event. Safe in production — no sensitive data is logged. See API Reference — Debug mode. |
children | ReactNode | ✅ | — | Your checkout UI |
sessionUrl, getSessionKey, or fetchWaxKey is required.
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 |
reset | () => void | Clears all mounted card and bank element fields without destroying the vault or refreshing the session. Call this after a declined payment so the customer can re-enter their details. The session and its remaining budget are preserved. |
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, session endpoint unreachable, or backend error. Render a fallback UI when set. |
tokenizeCount | number | Count of successful createToken/createBankToken calls in the current session. Resets to 0 on every session refresh. Use this to display “X attempts remaining” feedback or disable the pay button while a background session 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.