Skip to main content

Headless Integration

The headless integration allows you to perform identity verification programmatically without requiring users to be redirected away from your application. This is perfect for single-page applications, mobile apps, or any scenario where you want to maintain full control over the user experience.

Overview

Instead of redirecting users to complete OAuth flow, the headless integration:
  1. Creates an authorization request via API
  2. Opens a popup window for user authentication
  3. Polls for completion while user completes verification in popup
  4. Automatically closes popup and returns identity data
  5. Provides idv_rec for subsequent verification calls

Implementation

You’ll need your program API key from the admin dashboard to use the headless flow.

Framework Examples

React Hook

Vue 3 Composable

Next.js App Router

Security Considerations

Never expose your API key in client-side code! Always use server-side routes to make API calls with your secret key.

Client-Side Implementation

For client-side applications, create API routes that proxy requests:

Rate Limiting

The API includes rate limiting to prevent abuse:
  • Authorization requests: 10 per minute per API key
  • Status checks: 30 per minute per API key
Implement exponential backoff in your polling logic:

Troubleshooting

Common Issues

Popup Blocked
  • Ensure the authorization is triggered by a user action (click)
  • Check browser popup settings
  • Consider showing a message about allowing popups
Authorization Timeout
  • Authorization requests expire after 15 minutes
  • Implement proper error handling for expired requests
  • Consider shortening your polling timeout
API Key Issues
  • Verify your API key is correct and from the right environment
  • Ensure the associated program is active
  • Check that you’re using Bearer token format: Bearer pk_...

Debug Mode

Enable debug logging in development:
This will log all API requests and responses to help diagnose issues.

Migration from Redirect Flow

If you’re migrating from the traditional redirect-based flow:

Before (Redirect)

After (Headless)

The main benefits of the headless approach:
  • No page reload - maintain application state
  • Better UX - users stay on your site
  • Mobile friendly - works well on all devices
  • Customizable - full control over UI and error handling

Best Practices

  1. Always handle errors gracefully - network issues, popup blocking, etc.
  2. Implement proper loading states - show progress during authorization
  3. Use exponential backoff - for status polling to avoid rate limits
  4. Keep API keys secure - never expose them client-side
  5. Test thoroughly - across different browsers and devices
  6. Monitor usage - track authorization success rates and failure modes
Need help? Check out our examples repository or reach out in the Hack Club Slack.