Manual MFA with Browserbase Contexts

Persist MFA authentication across sessions using Browserbase Contexts

Demo preview
TypeScript
Source code
npx create-browser-app --template manual-mfa-with-contexts
uvx create-browser-app --template manual-mfa-with-contexts

Get started with MFA persistence using Browserbase Contexts

This template demonstrates how to persist authentication across sessions using Browserbase Contexts, eliminating MFA friction after the first login. The first session creates a context and completes MFA manually, saving the authentication state including MFA trust/remember device state. Subsequent sessions reuse the context with no MFA required. Perfect for payment automation, account management workflows, and compliance automation where you need to complete MFA once and then automate future sessions without MFA prompts.

Steps

  1. Create a new Browserbase context to persist authentication state
  2. First session: Navigate to login page and fill in credentials
  3. Detect MFA prompt and pause for manual MFA completion
  4. Wait for user to complete MFA in the browser session
  5. Context automatically saves authentication state including MFA trust
  6. Second session: Reuse context with no login or MFA required
  7. Verify authentication by checking logged-in state