Getting Started
Launch SafePassage biometric age verification on your site in minutes. This quick start focuses on the JavaScript SDK so you can ship without standing up server infrastructure.
Need Server-Side Control?
This guide covers the JavaScript SDK. For API-based integration with server-side session creation and validation, see the Server Integration Guide.
Prerequisites
- SafePassage account (sign up)
- Access to the SafePassage Dashboard to copy keys
- A web page where you will launch verification (camera access required)
Frontend Quick Start (SDK)
Step 1 — Copy your publishable key
- Log in to the SafePassage Dashboard
- Click API Keys in the sidebar
- Copy your publishable key (
pk_…)
Step 2 — Install the SDK
Option A: CDN
<script src="https://cdn.jsdelivr.net/npm/@safepassage/sdk@latest/safepassage.min.js"></script>
Option B: npm
npm install @safepassage/sdk
Step 3 — Launch verification
Local Server Required
You must serve this page from a web server (http://localhost:...). Opening the HTML file directly (file://) won't work because the verification redirect cannot return to local files. Use any of these:
npx serve .python3 -m http.server 8000- Your framework's dev server (
npm run dev)
<!DOCTYPE html>
<html>
<head>
<title>Age Verification</title>
<script src="https://cdn.jsdelivr.net/npm/@safepassage/sdk@latest/safepassage.min.js"></script>
</head>
<body>
<h1>Age Restricted Content</h1>
<button id="verify-btn">Verify Your Age</button>
<script>
// Check if running from a local file (won't work - need a server)
if (window.location.protocol === 'file:') {
document.getElementById('verify-btn').disabled = true;
document.getElementById('verify-btn').textContent = 'Requires local server';
document.body.insertAdjacentHTML('beforeend',
'<p style="color: red;">This page must be served from http://localhost. ' +
'Run: npx serve . or python3 -m http.server 8000</p>');
} else {
// Initialize with your publishable key (pk_...)
const sdk = new SafePassage({
apiKey: 'pk_your_key_here',
returnUrl: window.location.origin + window.location.pathname
});
document.getElementById('verify-btn').onclick = () => {
// Creates the verification session and opens the SafePassage flow
sdk.verify();
// Optional: tie the session to your own user ID
// sdk.verify({ externalUserId: currentUserId });
};
}
// Check the status parameter that SafePassage adds on redirect
const params = new URLSearchParams(window.location.search);
const status = params.get('status');
const sessionId = params.get('sessionId');
if (status === 'verified') {
// User passed verification - show success UI
document.body.insertAdjacentHTML('beforeend', '<p>Age verified!</p>');
// IMPORTANT: For production, validate sessionId server-side
// Client-side status can be forged. See Server Integration Guide.
console.log('Session ID for server validation:', sessionId);
} else if (status === 'failed') {
document.body.insertAdjacentHTML('beforeend', '<p>Verification failed.</p>');
}
</script>
</body>
</html>
Step 4 — Understand the user flow
- The SDK creates a session with your publishable key
- The user grants camera access and captures a selfie
- Depending on your verification mode, an ID scan may be requested
- SafePassage redirects back to your
returnUrlwithstatus, andsessionId
What's Next?
| Resource | Description |
|---|---|
| JavaScript SDK | Full SDK reference with all options |
| Server Integration | API-based integration with validation |
| Sessions API | API endpoint reference |
| Verification Modes | L1 vs L2 comparison |
| Code Examples | Ask support for ready-to-run examples |
Need Help?
- Email: support@safepassageapp.com