Skip to content

Configuration Reference

createAuthrim Options

The createAuthrim() function accepts an AuthrimConfig object:

import { createAuthrim } from '@authrim/web';
const auth = await createAuthrim({
// Required
issuer: 'https://auth.example.com',
clientId: 'my-app',
// Optional
enableOAuth: false,
storage: { ... },
silentLoginRedirectUri: 'https://myapp.com/callback.html',
});

Required Options

issuer

TypeRequiredDescription
stringYesAuthrim IdP URL

The base URL of your Authrim server. The SDK appends well-known paths for discovery, token endpoints, and Direct Auth endpoints.

issuer: 'https://auth.example.com'

clientId

TypeRequiredDescription
stringYesOAuth client ID

The client ID registered in the Authrim Admin panel.

clientId: 'my-application'

Optional Options

enableOAuth

TypeDefaultDescription
booleanfalseEnable OAuth/OIDC features

When true, the auth.oauth namespace becomes available, providing:

  • auth.oauth.popup.login() — Popup-based OAuth login
  • auth.oauth.silentAuth.check() — Iframe-based silent authentication
  • auth.oauth.trySilentLogin() — Top-level navigation SSO
  • auth.oauth.handleSilentCallback() — SSO callback handler
  • auth.oauth.buildAuthorizationUrl() — Manual authorization URL building
  • auth.oauth.handleCallback() — Manual callback handling
// Without OAuth (default)
const auth = await createAuthrim({
issuer: 'https://auth.example.com',
clientId: 'my-app',
});
// auth.oauth is undefined
// With OAuth
const authWithOAuth = await createAuthrim({
issuer: 'https://auth.example.com',
clientId: 'my-app',
enableOAuth: true,
});
// authWithOAuth.oauth is available

storage

TypeDefaultDescription
StorageOptionsSee belowStorage configuration
interface StorageOptions {
/** Key prefix for stored items (default: 'authrim') */
prefix?: string;
/** Storage backend (default: 'sessionStorage') */
storage?: 'memory' | 'sessionStorage' | 'localStorage';
}

Storage Types

TypeScopePersistenceSecurity
'memory'Current tabCleared on tab close / navigationMost secure (no DOM access)
'sessionStorage'Current tabSurvives reload, cleared on tab closeXSS-resistant (tab-scoped)
'localStorage'All tabsPersistent across browser restartsAccessible via XSS
// Strict security (SPA)
storage: { storage: 'memory' }
// Default (recommended for most apps)
storage: { storage: 'sessionStorage' }
// Persistent (remember me)
storage: { storage: 'localStorage', prefix: 'myapp-auth' }

silentLoginRedirectUri

TypeDefaultDescription
string${window.location.origin}/callback.htmlRedirect URI for silent SSO

Used by auth.oauth.trySilentLogin() and auth.oauth.handleSilentCallback(). Must be a page that calls handleSilentCallback().

silentLoginRedirectUri: 'https://myapp.com/auth/callback'

TypeScript: Conditional Types

The Authrim return type is conditional based on enableOAuth:

// enableOAuth: false (or omitted)
// Type: AuthrimBase
const auth = await createAuthrim({
issuer: '...',
clientId: '...',
});
auth.passkey // ✅ Available
auth.emailCode // ✅ Available
auth.social // ✅ Available
auth.session // ✅ Available
auth.oauth // ❌ undefined
// enableOAuth: true
// Type: AuthrimWithOAuth
const auth = await createAuthrim({
issuer: '...',
clientId: '...',
enableOAuth: true,
});
auth.passkey // ✅ Available
auth.oauth // ✅ Available

API Namespaces

Base (Always Available)

NamespaceDescription
auth.passkeyPasskey (WebAuthn) authentication
auth.emailCodeEmail code (OTP) authentication
auth.socialSocial provider authentication
auth.sessionSession management
auth.signInSign-in shortcuts
auth.signUpSign-up shortcuts
auth.signOut()Sign out
auth.on()Event subscription

OAuth (enableOAuth: true)

NamespaceDescription
auth.oauth.popupPopup-based OAuth login
auth.oauth.silentAuthIframe-based silent authentication
auth.oauth.trySilentLogin()Top-level navigation SSO
auth.oauth.handleSilentCallback()SSO callback handler
auth.oauth.buildAuthorizationUrl()Manual authorization URL
auth.oauth.handleCallback()Manual callback handling

Shortcuts

The SDK provides shortcut methods for common operations:

// Shortcut: auth.signIn.passkey()
// Equivalent: auth.passkey.login()
const { data, error } = await auth.signIn.passkey();
// Shortcut: auth.signIn.social('google')
// Equivalent: auth.social.loginWithPopup('google')
const { data, error } = await auth.signIn.social('google');
// Shortcut: auth.signUp.passkey({ email })
// Equivalent: auth.passkey.signUp({ email })
const { data, error } = await auth.signUp.passkey({ email: '[email protected]' });

Minimal Configuration

const auth = await createAuthrim({
issuer: 'https://auth.example.com',
clientId: 'my-app',
});

Full Configuration

const auth = await createAuthrim({
issuer: 'https://auth.example.com',
clientId: 'my-app',
enableOAuth: true,
storage: {
prefix: 'myapp',
storage: 'sessionStorage',
},
silentLoginRedirectUri: 'https://myapp.com/callback',
});

Next Steps