Build a React app that authenticates users with Humanity's OAuth flow and gates content based on biometric verification — using the Connect SDK directly without pre-built components.
This guide uses the sandbox environment.
Build a React app that authenticates users with Humanity's OAuth and gates access based on the isHuman biometric credential.
The Connect SDK gives you three core methods that you can use to control the flow with no pre-built components or abstraction layer.
After this guide you'll have:
A working Vite + React app that runs locally
The complete OAuth + PKCE flow wired up yourself
Biometric credential verification with live status display
A full sandbox test using mock credentials
Use this approach if you want granular control over authentication, need to understand the flow before abstracting it, or are building a custom integration.
Get these values from the Developer Portal under your application's sandbox settings.
Don't commit .env.local. The .gitignore step above prevents this, but double-check before pushing.
05. Build the app
Create the folder structure:
SDK initialization — src/lib/humanity.ts
Initialize the Connect SDK with your credentials. Store and retrieve the PKCE code verifier in session storage.
Auth context — src/hooks/useAuth.tsx
This context holds your access token, credentials, and metadata. Session storage keeps everything across page reloads during testing.
Button component — src/components/Button.tsx
A reusable button with multiple style variants.
Login button — src/components/LoginButton.tsx
This generates the SDK auth URL with PKCE and stores the code verifier before redirecting to Humanity.
Home page — src/pages/Home.tsx
Display the verification card and redirect authenticated users to the dashboard.
OAuth callback — src/pages/OAuthCallback.tsx
This page handles the redirect back from Humanity. It exchanges your authorization code for an access token and checks for the is_human credential.
Dashboard — src/pages/Dashboard.tsx
Display the biometric status. The is_human credential can be true, false, or missing—the dashboard shows all three.
App routing — src/App.tsx
Entry point — src/main.tsx
Stylesheet — src/index.css
The app uses a plain CSS stylesheet — no Tailwind. All component classes (biometric-status-card, dashboard-shell, home-screen, etc.) and the utility classes used throughout the components are defined here.
06. Run and test
Start the dev server:
Open http://localhost:5173. You should see the home page with a "Verify" button.
Click Verify
Sign in with your sandbox account (the one with the mock is_human credential)
You'll land on the dashboard showing Human verified
If you test without a credential, the dashboard shows Not verified with value false or missing.
How it works
The whole flow comes down to three SDK methods:
buildAuthUrl() — creates an authorization URL with PKCE. Store the code verifier in session storage.
exchangeCodeForToken() — swaps the authorization code for an access token using the stored verifier.
verifyPresets() — checks which credentials the user has. In this case, just is_human.
The app keeps tokens and credential data in session storage. On the dashboard, it pulls out the is_human through isHuman mapping value and displays the result.
Next Steps
Ready to build a more complex application?
The Personalized Newsletter App takes everything you built here and moves it to a full-stack Next.js setup — tokens handled server-side, clientSecret kept out of the browser, and session storage replaced with HTTP-only cookies.
You'll work with batch preset verification, the Query Engine, and MongoDB to build something that actually acts on verified identity: a personalized content feed driven by what Humanity knows about the user.