npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@loginradius/loginradius-js

v3.0.0-rc.1.1

Published

A framework-agnostic JavaScript SDK for integrating LoginRadius authentication and identity management

Readme

@loginradius/loginradius-js

A framework-agnostic JavaScript SDK for integrating LoginRadius authentication and identity management into any web application.

Features

  • 🚀 Framework-agnostic - Works with vanilla JavaScript, Vue, Angular, Svelte, or any framework
  • 📦 Lightweight - Optimized bundle size using Preact
  • 🎯 Simple API - Easy-to-use imperative interface
  • 🔒 Secure - Built on LoginRadius's proven authentication platform
  • 📘 TypeScript - Full TypeScript support with type definitions
  • ⚡ Modern - ES2017+ with ES Modules and CommonJS support

Installation

npm install @loginradius/loginradius-js

or

yarn add @loginradius/loginradius-js

or

pnpm add @loginradius/loginradius-js

All dependencies are included automatically.

Quick Start

import { LoginRadiusSDK } from '@loginradius/loginradius-js';

// Initialize the SDK
const sdk = new LoginRadiusSDK({
  appName: 'your-app-name',
  apiKey: 'your-api-key',
});

// Render a login form
sdk.init('login', {
  container: '#login-container',
  onSuccess: (data) => {
    console.log('Login successful:', data);
    // Handle successful login
  },
  onError: (error) => {
    console.error('Login error:', error);
    // Handle error
  },
});

Usage

Initialize the SDK

import { LoginRadiusSDK } from '@loginradius/loginradius-js';

const sdk = new LoginRadiusSDK({
  appName: 'your-app-name',
  apiKey: 'your-api-key',
  // Optional configuration
  sott: 'your-sott-token',
  verificationUrl: 'https://your-domain.com/verify',
  resetPasswordUrl: 'https://your-domain.com/reset-password',
});

Available Actions

The SDK supports various authentication flows:

Login

sdk.init('login', {
  container: '#login-container',
  onSuccess: (data) => console.log('Login successful:', data),
  onError: (error) => console.error('Login error:', error),
});

Registration

sdk.init('registration', {
  container: '#register-container',
  onSuccess: (data) => console.log('Registration successful:', data),
  onError: (error) => console.error('Registration error:', error),
});

Forgot Password

sdk.init('forgotPassword', {
  container: '#forgot-password-container',
  onSuccess: (data) => console.log('Password reset email sent:', data),
  onError: (error) => console.error('Error:', error),
});

Custom Workflow

sdk.init('workflow', {
  container: '#workflow-container',
  workflowName: 'your-workflow-name',
  clientId: 'your-client-id',
  onSuccess: (data) => console.log('Workflow completed:', data),
  onError: (error) => console.error('Workflow error:', error),
});

All Available Actions

  • login - Login form
  • registration - Registration form
  • forgotPassword - Forgot password flow
  • auth - Authentication flow
  • orgInvite - Organization invitation
  • passwordlessLogin - Passwordless login
  • profileEditor - Profile editor
  • workflow - Custom workflow
  • verifyToken - Token verification
  • changePin - Change PIN
  • changePassword - Change password
  • linkAccount - Link social account
  • addEmail - Add email
  • personalDetails - Edit personal details
  • resetBackupCode - Reset backup codes
  • socialLogin - Social login
  • editPhone - Edit phone number
  • verifyEmailPhone - Verify email/phone
  • editUsername - Edit username
  • setupTwoFactorAuth - Setup 2FA
  • addPasskey - Add passkey
  • deleteAccount - Delete account

Cleanup

// Destroy a specific container
sdk.destroy('login-container');

TypeScript Support

The SDK includes full TypeScript definitions:

import {
  LoginRadiusSDK,
  LoginRadiusOptions,
  ActionType,
  ApiError,
} from '@loginradius/loginradius-js';

const options: LoginRadiusOptions = {
  appName: 'your-app-name',
  apiKey: 'your-api-key',
};

const sdk = new LoginRadiusSDK(options);

const action: ActionType = 'login';

sdk.init(action, {
  container: '#login-container',
  onSuccess: (data: any) => {
    console.log(data);
  },
  onError: (error: ApiError) => {
    console.error(error);
  },
});

Framework Examples

Vanilla JavaScript

<!DOCTYPE html>
<html>
  <head>
    <title>LoginRadius JS SDK</title>
  </head>
  <body>
    <div id="login-container"></div>

    <script type="module">
      import { LoginRadiusSDK } from '@loginradius/loginradius-js';

      const sdk = new LoginRadiusSDK({
        appName: 'your-app-name',
        apiKey: 'your-api-key',
      });

      sdk.init('login', {
        container: '#login-container',
        onSuccess: (data) => console.log('Success:', data),
      });
    </script>
  </body>
</html>

Vue 3

<template>
  <div ref="loginContainer"></div>
</template>

<script setup>
import { ref, onMounted, onUnmounted } from 'vue';
import { LoginRadiusSDK } from '@loginradius/loginradius-js';

const loginContainer = ref(null);
let sdk;

onMounted(() => {
  sdk = new LoginRadiusSDK({
    appName: 'your-app-name',
    apiKey: 'your-api-key',
  });

  sdk.init('login', {
    container: loginContainer.value,
    onSuccess: (data) => console.log('Success:', data),
  });
});

onUnmounted(() => {
  if (loginContainer.value) {
    sdk.destroy(loginContainer.value.id);
  }
});
</script>

Angular

import {
  Component,
  ElementRef,
  ViewChild,
  AfterViewInit,
  OnDestroy,
} from '@angular/core';
import { LoginRadiusSDK } from '@loginradius/loginradius-js';

@Component({
  selector: 'app-login',
  template: '<div #loginContainer></div>',
})
export class LoginComponent implements AfterViewInit, OnDestroy {
  @ViewChild('loginContainer') loginContainer!: ElementRef;
  private sdk!: LoginRadiusSDK;

  ngAfterViewInit() {
    this.sdk = new LoginRadiusSDK({
      appName: 'your-app-name',
      apiKey: 'your-api-key',
    });

    this.sdk.init('login', {
      container: this.loginContainer.nativeElement,
      onSuccess: (data) => console.log('Success:', data),
    });
  }

  ngOnDestroy() {
    if (this.loginContainer?.nativeElement?.id) {
      this.sdk.destroy(this.loginContainer.nativeElement.id);
    }
  }
}

Svelte

<script>
  import { onMount, onDestroy } from 'svelte';
  import { LoginRadiusSDK } from '@loginradius/loginradius-js';

  let loginContainer;
  let sdk;

  onMount(() => {
    sdk = new LoginRadiusSDK({
      appName: 'your-app-name',
      apiKey: 'your-api-key',
    });

    sdk.init('login', {
      container: loginContainer,
      onSuccess: (data) => console.log('Success:', data),
    });
  });

  onDestroy(() => {
    if (loginContainer?.id) {
      sdk.destroy(loginContainer.id);
    }
  });
</script>

<div bind:this={loginContainer}></div>

API Reference

LoginRadiusSDK

Constructor

new LoginRadiusSDK(options: LoginRadiusOptions)

Methods

init(action, options)

Initialize and render an authentication flow.

sdk.init(action: ActionType, options: InitOptions): void
destroy(containerId)

Destroy and cleanup a rendered flow.

sdk.destroy(containerId: string): void

Properties

util

Access to utility functions.

sdk.util: Utilities
$hooks

Access to SDK hooks for advanced customization.

sdk.$hooks: any

Browser Support

  • Modern browsers (Chrome, Firefox, Safari, Edge)
  • ES2017+ support required
  • For older browsers, use appropriate polyfills

Related Packages

License

MIT

Support