A Vanilla JavaScript sample application using the @authrim/web SDK. Loads the SDK via CDN, no build step required.
- Passkey Authentication: Login and signup with biometrics or security keys
- Email Code Authentication: Login with one-time code sent to email
- Social Login: Login with Google, GitHub, or Apple
- Session Management: Check login status, view profile, logout
Copy config.example.js to config.js and set the values from your Authrim dashboard.
cp config.example.js config.jsThen edit config.js:
window.AUTHRIM_CONFIG = {
issuer: 'https://your-tenant.authrim.com',
clientId: 'your-client-id',
};# Using npx serve
npx serve .
# Or use VSCode Live Server extensionNavigate to http://localhost:3000 (or your Live Server URL).
- Fork this repository to your GitHub account
- Edit
config.jswith your issuer and clientId - Commit and push changes
- Log in to Cloudflare Pages
- Click "Create a project" → "Connect to Git"
- Select your forked repository
- Build settings:
- Framework preset: None
- Build command: (leave empty)
- Build output directory:
/or.
- Click "Save and Deploy"
- Download this repository
- Edit
config.js - Log in to Cloudflare Pages
- Click "Create a project" → "Direct Upload"
- Enter a project name
- Drag and drop the entire folder
- Click "Deploy site"
example-web/
├── README.md # This file
├── config.example.js # Configuration template
├── config.js # ★ Configuration file (must create from example)
├── index.html # Home page
├── login.html # Login page
├── callback.html # OAuth callback handler
├── profile.html # Profile page
└── css/
└── style.css # Stylesheet
- Checks login status
- When logged out: Shows link to login page
- When logged in: Shows user info and link to profile
- Passkey login/signup
- Email code authentication (2-step: email input → code input)
- Social login (Google, GitHub, Apple)
- Handles social login callback
- Redirects to home on success
- Shows error message on failure
- Requires authentication (redirects if not logged in)
- Displays detailed user information
- Shows session information
- Logout functionality
In your Authrim Admin panel, configure the following:
- Client ID: Set in
config.jsasclientId - Allowed Redirect URIs: Add your deployment URL
- e.g.,
https://your-app.pages.dev/callback.html
- e.g.,
- Allowed Origins: Add your deployment origin
- e.g.,
https://your-app.pages.dev
- e.g.,
- SDK: @authrim/web
- CDN: unpkg (
https://unpkg.com/@authrim/web@latest/dist/authrim-web.umd.global.js) - Supported Browsers: Chrome, Firefox, Safari, Edge (latest versions)
- No Framework Required: Vanilla JavaScript only
To enable diagnostic logging for debugging or OIDF conformance testing:
Edit config.js and set diagnostic options:
window.AUTHRIM_CONFIG = {
issuer: 'https://your-tenant.authrim.com',
clientId: 'your-client-id',
diagnostic: {
enabled: true,
collectLogs: true,
sendToServer: false, // Set to true to send logs to server
}
};Open browser console and run:
window.AUTHRIM_DIAGNOSTIC_LOGGER?.getLogs()To download logs as JSON file:
window.AUTHRIM_DIAGNOSTIC_LOGGER?.downloadLogs()To automatically send logs to the server for analysis:
window.AUTHRIM_CONFIG = {
// ... other config
diagnostic: {
enabled: true,
collectLogs: true,
sendToServer: true,
serverUrl: 'https://your-tenant.authrim.com',
}
};Note: example-web is a public client and does not require clientSecret.
Edit config.js and set your actual Authrim tenant URL and client ID
- Verify your browser supports WebAuthn
- Ensure you're running on HTTPS (localhost is allowed as exception)
- Verify social providers are enabled in your Authrim configuration
- Check that redirect URIs are correctly configured
- Ensure
callback.htmlURL is included in the allowed redirect URIs
Apache 2.0