Copy this code to add authentication to your site in under 5 minutes
Configure your API key and Site ID above, then click "Initialize SDK"
Enter your email to receive a login link. No password needed!
Email-based authentication eliminates password management
Credentials persist for 90 days - no repeated logins
Cryptographic nonces prevent replay attacks
Client-side verification with 7-day cache
Copy and paste this code into your website:
<!-- Add before </body> --> <script src="https://lemma.id/static/js/lemma-wallet.js"></script> <script src="https://lemma.id/static/js/lemma-auth-simple.js"></script>
const auth = new LemmaAuth({ apiKey: 'YOUR_API_KEY', // From lemma.id/dashboard siteId: 'YOUR_SITE_ID', // Your site identifier debug: true // Enable console logs });
// Check if user has valid credential const isAuth = await auth.isAuthenticated(); if (isAuth) { // User is authenticated - show protected content const user = await auth.getUser(); console.log('Authenticated as:', user.email); showDashboard(); } else { // Show login form showLoginForm(); }
// Send login email to user async function requestAccess(email) { const result = await auth.sendLoginEmail(email); if (result.success) { alert('Check your email to complete login!'); } else { alert('Error: ' + result.error); } }
// Check specific permission const isAdmin = await auth.hasPermission('admin'); if (!isAdmin) { window.location.href = '/unauthorized'; }
new LemmaAuth({ apiKey: 'string', // Required: Your API key siteId: 'string', // Required: Your site ID siteDomain: 'string', // Optional: defaults to window.location.hostname debug: boolean // Optional: enable debug logging })
Returns Promise<boolean>. Pass true to skip nonce verification for faster checks.
Returns Promise<{email, role, authenticated, credential}> or null if not authenticated.
Sends login email. Options: {role, redirectUrl}. Returns {success, message}.
Returns Promise<boolean>. Checks if user has specific permission.
Clears credentials from browser. Returns Promise<void>.
Client-side verification: ~63 microseconds (WebCrypto API)
Works offline: Yes, with 7-day cache
Credential duration: 90 days