JavaScript SDK (verifa.js)
The Verifa JavaScript SDK handles the frontend capture experience — opening the verification UI as a popup, modal, or redirect. Your backend creates the session, the SDK handles the rest.
Recommended integration
The most secure and production-ready approach: your backend creates the session
using a secret API key, then passes the capture_url to the frontend.
1. Add the script
2. Create a session on your server
Your backend calls the Verifa API with a secret key:
Python
JavaScript
3. Open the capture UI on your frontend
This is how Stripe, Persona, and other platforms work — the API key never leaves your server. The frontend only receives a short-lived capture URL.
4. Get the result
Results contain PII and must be retrieved server-side:
Or receive results via webhook (recommended for production).
Quick start (publishable key)
For prototyping or simple integrations where you don’t have a backend, you can use a publishable key to create sessions directly from the browser.
Publishable keys are designed for quick prototyping and simple use cases. For production applications, use the recommended integration above — it keeps your API key on your server and gives you full control over session creation.
Publishable keys (vk_pub_*) can only create sessions — they cannot read
results, access PII, or manage any resources. Create one in the dashboard under
Developers > API Keys.
API reference
Verifa.open(options) — recommended
Open the capture UI for a session your backend already created. No API key needed in the browser.
Returns: Promise<{ sessionId: string, status: string }>
Verifa.init(options) — publishable key only
Initialize the SDK with a publishable key. Only needed if using
startVerification().
Verifa.startVerification(options) — publishable key only
Create a session using a publishable key and open the capture UI. Requires
Verifa.init() first.
Returns: Promise<{ sessionId: string, status: string }>
Display modes
Popup (default)
Opens the capture UI in a centered popup window. Best for desktop.
If the browser blocks the popup, onError fires. Fall back to modal mode.
Modal
Opens the capture UI in a full-screen overlay with an iframe. Works on desktop and mobile. Closes with the X button, backdrop click, or Escape key.
Redirect
Navigates the browser to the capture page. After completion, the user returns
to the redirect_url you specified when creating the session.
The user lands back on your redirect URL with query parameters:
Framework examples
React
Vue
Vanilla JavaScript
Error handling
Common errors:
Sandbox testing
Use sandbox API keys to test without real verifications. In sandbox mode, the capture flow lets you choose the outcome (approve, reject, or needs review).
Browser support
The SDK uses fetch, Promise, and postMessage, supported in all modern
browsers:
- Chrome 42+, Firefox 39+, Safari 10.1+, Edge 14+
No polyfills required for any browser released after 2017.
Security
- No API key in the browser — With
Verifa.open(), the secret key stays on your server. The frontend only receives a short-lived capture URL (20 min). - No PII exposure — The SDK never receives verification results, document images, or personal data.
- Token-based capture — Document uploads use a session-specific token, not any API key.
Related
- Web Capture Flow — Full server-side integration guide
- Choosing an Integration Method — Compare all integration options
- Authentication — API key types and scopes
- Webhooks Guide — Receive results in real-time
- Testing — Sandbox testing guide