TryMellon

Installation

Install and configure the TryMellon JavaScript SDK.

Installation

Install from npm

npm install @trymellon/js

Entry points

ImportUse case
@trymellon/jsCore SDK — Vanilla JS, Svelte, Node
@trymellon/js/reactReact 18+ hooks & provider
@trymellon/js/vueVue 3 Composition API composables
@trymellon/js/angularAngular standalone service & DI
@trymellon/js/uiWeb Components (<trymellon-auth>, <trymellon-auth-modal>)
@trymellon/js/umdUMD bundle — window.TryMellon via <script> tag

Initialize the client

import { TryMellon } from '@trymellon/js'

const clientResult = TryMellon.create({
  appId: 'YOUR_APP_ID',             // Required: Application ID from dashboard
  publishableKey: 'cli_xxxx',       // Required: Client ID (safe for browser)
  apiBaseUrl: 'https://api.trymellonauth.com', // Optional, default
  timeoutMs: 30000,                 // Optional, default 30000
  maxRetries: 3,                    // Optional, default 3
  retryDelayMs: 1000,               // Optional, default 1000
})

if (!clientResult.ok) {
  console.error(clientResult.error.message);
  throw clientResult.error;
}
const client = clientResult.value;

Where to get your credentials

  1. Sign up at the TryMellon dashboard.
  2. Create an Application — you’ll receive an App ID (UUID) and a Client ID (starts with cli_).
  3. Add your domain to Allowed Origins so the API accepts requests from your frontend.

Configuration options

OptionRequiredDefaultDescription
appIdYesApplication ID. Sent as X-App-Id header.
publishableKeyYesClient ID for client-side auth (safe for the browser).
apiBaseUrlNo'https://api.trymellonauth.com'API base URL. Override for self-hosted or staging environments.
timeoutMsNo30000HTTP request timeout (ms). Range: 1000–300000.
maxRetriesNo3Retries for transient network errors. Range: 0–10.
retryDelayMsNo1000Delay between retries (ms). Range: 100–10000.
loggerNoconsoleCustom logger implementing the Logger interface.
sandboxNofalseSkip API & WebAuthn calls; return a fixed token instantly. See Sandbox mode.
sandboxTokenNoSANDBOX_SESSION_TOKENCustom token returned in sandbox mode.
enableTelemetryNofalseOpt-in anonymous event + latency tracking.

Runtime compatibility

EnvironmentSupported
Modern browsers (Chrome, Safari, Firefox, Edge)Yes
Node.js 18+ (SSR/server validation)Yes
Edge runtimes (Cloudflare Workers, Vercel Edge)Yes
React NativeNo (WebAuthn requires a browser)

The SDK uses only globalThis.crypto and standard fetch — no Node-specific APIs.

For register and authenticate options you can use externalUserId (camelCase).