Next.js (App Router) example
Four files to copy into a Next.js 14+ application. They are reference code: this folder is not a runnable project and is not executed by the SDK test suite.
| File | Runs on | Role |
|---|---|---|
lib/identity.ts |
server | the only place where the secret key is read |
app/api/identity/session/route.ts |
server | creates a verification session for the signed-in user |
app/api/identity/webhook/route.ts |
server | verifies the signature on the raw body, deduplicates, stores the status |
app/verify/VerifyIdentity.tsx |
browser | button that asks the route above for a session and opens the hosted page |
Environment (server only, never prefixed with NEXT_PUBLIC_):
text
MLID_SECRET_KEY=mlid_sk_test_...
MLID_WEBHOOK_SECRET=whsec_...
MLID_BASE_URL=https://identity.spboucher.aiFor modal mode, the origin of your site must be listed in the application's allowed_origins, otherwise the
browser refuses to display the verification page in a frame. Redirect mode needs return_url to be allowed.