For the complete documentation index, see llms.txt. This page is also available as Markdown.

Embed a Claim Button

How-To Guide: Add a credential claim button to any website using the LearnCard Embed SDK

Add a "Claim Credential" button to any webpage. When a user clicks it, a modal walks them through email verification and deposits the credential into their LearnCard wallet.

~15 min ยท Start here โ€” the CLI sets up everything it needs.

The one-line version

npx @learncard/cli embed --domains https://yoursite.com

Sets up LearnCard to sign for you, registers an integration whitelisted to your origins, saves the publishable key to .env, and writes claim-button.html โ€” a working page with the key filled in. Serve it from a whitelisted origin (not file://) and click the button.

The rest of this page is the same setup by hand.

This is for external websites that want to award credentials to visitors. If you're building an app that runs inside the LearnCard App Store, see Build an App Inside LearnCard instead.

Step 1: Get a publishable key

The button is keyed to an integration โ€” a record that holds your allowed origins and a publishable key (pk_โ€ฆ). Either:

  • run npx @learncard/cli embed --domains https://yoursite.com (creates it and saves PUBLISHABLE_KEY to .env), or

  • in the Developer Portal open Guides โ†’ Embed Claim Button, follow the setup, and copy the key from the Embed Code tab.

Credentials claimed through the button are signed by your primary signing authority; the CLI sets one up if you don't have one.

Step 2: Add the SDK

<script src="https://cdn.jsdelivr.net/npm/@learncard/embed-sdk@latest/dist/learncard.js"></script>
npm install @learncard/embed-sdk
import { init } from '@learncard/embed-sdk';

Step 3: Initialize the SDK

Add a target element and call init():

The credential name must match a template you created in the Developer Portal. The SDK resolves it server-side.

Step 4: Customize Branding (Optional)

Step 5: Handle Success (Optional)

After claiming, the SDK opens the wallet in a new tab (deep-linked to the credential via handoffUrl) and shows a success screen. Hook into this with onSuccess:

To suppress the automatic wallet redirect entirely, set branding.walletUrl: '':

Complete Example

This is the file npx @learncard/cli embed writes, with PUBLISHABLE_KEY_PLACEHOLDER replaced by your key:

Whitelisted Domains

The API only accepts claims from domains whitelisted in the Embed Code tab of your Developer Portal. Add your production domain before going live.

During local development, localhost is allowed automatically.

Troubleshooting

"This integration could not be found" Your publishableKey doesn't match an active integration. Check the key from your Developer Portal Embed Code tab and ensure your domain is whitelisted.

Credential not appearing after claim The credential lands in the user's inbox and is finalized when they open their wallet. To verify immediately, check the Developer Portal's activity tab.

OTP not arriving In local dev, check your brain-service logs โ€” OTP codes are printed there when no email provider is configured.

See Also

Last updated

Was this helpful?