Sign In

@authon/js

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@authon/js

Authon core browser SDK — ShadowDOM login modal, OAuth, session management

Source
npmnpm
Version
0.7.13
Version published
Weekly downloads
125
12400%
Maintainers
1
Weekly downloads
 
Created
Source

English | 한국어

@authon/js

Drop-in browser authentication SDK — Auth0 alternative, open-source auth

npm version License

Prerequisites

Before installing the SDK, create an Authon project and get your API keys:

  • Create a project at Authon Dashboard

    • Click "Create Project" and enter your app name
    • Select the authentication methods you want (Email/Password, OAuth providers, etc.)
  • Get your API keys from Project Settings → API Keys

    • Publishable Key (pk_live_...) — use in your frontend code
    • Test Key (pk_test_...) — for development, enables Dev Teleport
  • Configure OAuth providers (optional) in Project Settings → OAuth

    • Add Google, Apple, GitHub, etc. with their respective Client ID and Secret
    • Set the redirect URL to https://api.authon.dev/v1/auth/oauth/redirect

Test vs Live keys: Use pk_test_... during development. Switch to pk_live_... before deploying to production. Test keys use a sandbox environment with no rate limits.

Install

npm install @authon/js

Quick Start

<!-- index.html -->
<!DOCTYPE html>
<html>
<head><title>My App</title></head>
<body>
  <button id="sign-in-btn">Sign In</button>
  <div id="user-info"></div>

  <script type="module">
    import { Authon } from '@authon/js';

    const authon = new Authon('pk_live_YOUR_PUBLISHABLE_KEY');

    document.getElementById('sign-in-btn').addEventListener('click', () => {
      authon.openSignIn();
    });

    authon.on('signedIn', (user) => {
      document.getElementById('user-info').textContent = `Hello, ${user.email}`;
      document.getElementById('sign-in-btn').style.display = 'none';
    });
  </script>
</body>
</html>

Common Tasks

Add Google OAuth Login

import { Authon } from '@authon/js';

const authon = new Authon('pk_live_YOUR_PUBLISHABLE_KEY');

// Opens popup, falls back to redirect if blocked
await authon.signInWithOAuth('google');

// Force redirect mode
await authon.signInWithOAuth('google', { flowMode: 'redirect' });

// Supported providers: google, apple, github, discord, facebook,
// microsoft, kakao, naver, line, x

Add Email/Password Auth

import { Authon } from '@authon/js';

const authon = new Authon('pk_live_YOUR_PUBLISHABLE_KEY');

// Sign up
const user = await authon.signUpWithEmail('user@example.com', 'MyP@ssw0rd', {
  displayName: 'Alice',
});

// Sign in
const user = await authon.signInWithEmail('user@example.com', 'MyP@ssw0rd');

Get Current User

// Synchronous — no network request
const user = authon.getUser();
// { id, email, displayName, avatarUrl, emailVerified, ... }

const token = authon.getToken();
// Use token for authenticated API calls

Open Built-in Sign-In Modal

// ShadowDOM modal — no CSS conflicts with your app
await authon.openSignIn();
await authon.openSignUp();

Handle Sign Out

await authon.signOut();

Add Passkey (WebAuthn) Login

// Register passkey (user must be signed in)
const credential = await authon.registerPasskey('My MacBook');

// Sign in with passkey
const user = await authon.authenticateWithPasskey();

Add Web3 Wallet Login (MetaMask)

const { message } = await authon.web3GetNonce('0xAbc...', 'evm', 'metamask', 1);
const signature = await window.ethereum.request({
  method: 'personal_sign',
  params: [message, '0xAbc...'],
});
const user = await authon.web3Verify(message, signature, '0xAbc...', 'evm', 'metamask');

Add MFA (TOTP)

import { Authon, AuthonMfaRequiredError } from '@authon/js';

// Setup MFA (user must be signed in)
const setup = await authon.setupMfa();
document.getElementById('qr').innerHTML = setup.qrCodeSvg;
await authon.verifyMfaSetup('123456'); // code from authenticator app

// Sign in with MFA
try {
  await authon.signInWithEmail('user@example.com', 'password');
} catch (err) {
  if (err instanceof AuthonMfaRequiredError) {
    const user = await authon.verifyMfa(err.mfaToken, '123456');
  }
}

Listen to Auth Events

authon.on('signedIn', (user) => console.log('Signed in:', user.email));
authon.on('signedOut', () => console.log('Signed out'));
authon.on('error', (err) => console.error(err.message));
authon.on('mfaRequired', (mfaToken) => { /* show MFA dialog */ });
authon.on('tokenRefreshed', (token) => { /* update API client */ });

Environment Variables

VariableRequiredDescription
AUTHON_PUBLISHABLE_KEYYesProject publishable key (pk_live_... or pk_test_...)
AUTHON_API_URLNoOptional — defaults to api.authon.dev

API Reference

Constructor

new Authon(publishableKey: string, config?: AuthonConfig)
Config OptionTypeDefaultDescription
apiUrlstringhttps://api.authon.devAPI base URL
mode'popup' | 'embedded''popup'Modal display mode
theme'light' | 'dark' | 'auto''auto'UI theme
localestring'en'UI locale
containerIdstring--Element ID for embedded mode
appearancePartial<BrandingConfig>--Override branding

Auth Methods

MethodReturns
openSignIn()Promise<void>
openSignUp()Promise<void>
signInWithEmail(email, password)Promise<AuthonUser>
signUpWithEmail(email, password, meta?)Promise<AuthonUser>
signInWithOAuth(provider, options?)Promise<void>
signOut()Promise<void>
getUser()AuthonUser | null
getToken()string | null

Passwordless

MethodReturns
sendMagicLink(email)Promise<void>
sendEmailOtp(email)Promise<void>
verifyPasswordless({ token?, email?, code? })Promise<AuthonUser>

Passkeys (WebAuthn)

MethodReturns
registerPasskey(name?)Promise<PasskeyCredential>
authenticateWithPasskey(email?)Promise<AuthonUser>
listPasskeys()Promise<PasskeyCredential[]>
renamePasskey(id, name)Promise<PasskeyCredential>
revokePasskey(id)Promise<void>

Web3

MethodReturns
web3GetNonce(address, chain, walletType, chainId?)Promise<Web3NonceResponse>
web3Verify(message, signature, address, chain, walletType)Promise<AuthonUser>
listWallets()Promise<Web3Wallet[]>
linkWallet(params)Promise<Web3Wallet>
unlinkWallet(walletId)Promise<void>

MFA

MethodReturns
setupMfa()Promise<MfaSetupResponse & { qrCodeSvg }>
verifyMfaSetup(code)Promise<void>
verifyMfa(mfaToken, code)Promise<AuthonUser>
getMfaStatus()Promise<MfaStatus>
disableMfa(code)Promise<void>
regenerateBackupCodes(code)Promise<string[]>

Organizations

MethodReturns
organizations.list()Promise<OrganizationListResponse>
organizations.create(params)Promise<AuthonOrganization>
organizations.get(orgId)Promise<AuthonOrganization>
organizations.update(orgId, params)Promise<AuthonOrganization>
organizations.delete(orgId)Promise<void>
organizations.invite(orgId, params)Promise<OrganizationInvitation>

Events

EventPayload
signedInAuthonUser
signedOut--
tokenRefreshedstring
mfaRequiredstring (mfaToken)
passkeyRegisteredPasskeyCredential
web3ConnectedWeb3Wallet
errorError

Comparison

FeatureAuthonClerkAuth.js
PricingFree$25/mo+Free
OAuth providers10+20+80+
ShadowDOM modalYesNoNo
MFA/PasskeysYesYesPlugin
Web3 authYesNoNo
OrganizationsYesYesNo

License

MIT

Keywords

authon

FAQs

Package last updated on 06 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts