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

@supertokens-plugins/user-banning-react

v0.2.1

Published

User Banning Plugin for SuperTokens

Readme

SuperTokens Plugin User Banning

Add user banning functionality to your SuperTokens React application. This plugin provides a user-friendly interface for administrators to ban/unban users and integrates seamlessly with the backend user banning plugin.

Installation

npm install @supertokens-plugins/user-banning-react

Quick Start

Frontend Configuration

Initialize the plugin in your SuperTokens frontend configuration:

import SuperTokens from "supertokens-auth-react";
import UserBanningPlugin from "@supertokens-plugins/user-banning-react";

SuperTokens.init({
  appInfo: {
    // your app info
  },
  recipeList: [
    // your recipes
  ],
  plugins: [
    UserBanningPlugin.init({
      userBanningPermission: "ban-user", // Optional: defaults to "ban-user"
      bannedUserRole: "banned", // Optional: defaults to "banned"
      onPermissionFailureRedirectPath: "/", // Optional: defaults to "/"
    }),
  ],
});

[!IMPORTANT]
You also have to install and configure the backend plugin. Make sure that the roles and permissions are the same.

User Banning Interface

The plugin provides a complete administrative interface accessible at /admin/ban-user. This page includes:

  • Tenant Selection: Input tenant ID for multi-tenant applications
  • Ban Status Check: View current ban status for any user
  • Ban/Unban Actions: One-click ban and unban functionality
  • Permission Protection: Automatically protects the interface with required permissions

Configuration Options

| Option | Type | Default | Description | | --------------------------------- | ------ | ------------ | ---------------------------------------------- | | userBanningPermission | string | "ban-user" | Permission required to access banning features | | bannedUserRole | string | "banned" | Role assigned to banned users | | onPermissionFailureRedirectPath | string | "/" | Redirect path when permission check fails |

Hooks and Utilities

usePlugin Hook

Access exposed plugin functionality in your custom components:

import { usePlugin } from "@supertokens-plugins/user-banning-react";

function MyAdminComponent() {
  const { api, pluginConfig, t } = usePlugin();

  const handleBanUser = async (email: string) => {
    try {
      await api.updateBanStatus("public", email, true);
      console.log("User banned successfully");
    } catch (error) {
      console.error("Failed to ban user:", error);
    }
  };

  return (
    <div>
      <h2>{t("PL_UB_BAN_PAGE_TITLE")}</h2>
      {/* Your custom UI */}
    </div>
  );
}

API Methods

The plugin provides these API methods through the usePlugin hook:

getBanStatus

Check if a user is banned:

const { api } = usePlugin();

// Check ban status
const result = await api.getBanStatus("public", "[email protected]");
if (result.status === "OK") {
  console.log("User is banned:", result.banned);
} else {
  console.error("Error:", result.message);
}

updateBanStatus

Ban or unban a user:

const { api } = usePlugin();

// Ban a user
await api.updateBanStatus("public", "[email protected]", true);

// Unban a user
await api.updateBanStatus("public", "[email protected]", false);

Translation Keys

The plugin provides these translations for customizing the interface. THey can be found in the translations.ts file.

Requirements

  • SuperTokens React SDK >= 0.50.0
  • SuperTokens User Banning Backend Plugin
  • UserRoles recipe must be initialized

Related