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

react-tenant-theme

v0.1.2

Published

> A lightweight, production-ready theming engine for multi-tenant React applications.

Readme

react-tenant-theme

A lightweight, production-ready theming engine for multi-tenant React applications.

TypeScript React License

Docs: Live documentation & examples · npm: react-tenant-theme · Repo: GitHub


✨ Why This Exists

Modern SaaS applications often require:

  • Multi-tenant branding
  • Light/Dark mode per tenant
  • Scalable design token systems
  • SSR compatibility
  • Zero visual flicker on reload

Most theming solutions become fragile at scale.

react-tenant-theme provides a clean, architecture-first approach to solving this problem using CSS variables and a structured tenant → theme → token model.


🔑 Key Features

  • ✅ Multi-tenant support
  • ✅ Per-tenant theme switching
  • ✅ Type-safe token definitions
  • ✅ CSS variable-based design tokens
  • ✅ SSR-safe (Next.js compatible)
  • ✅ No flash of default theme
  • ✅ LocalStorage persistence
  • ✅ Minimal runtime overhead

📦 Installation

npm install react-tenant-theme
# or
pnpm add react-tenant-theme
# or
yarn add react-tenant-theme

🚀 Quick Start

1️⃣ Define Tenants & Themes

import type { TenantDefinition } from "react-tenant-theme";

const tenants: TenantDefinition[] = [
  {
    id: "acme",
    name: "Acme Inc",
    defaultThemeId: "light",
    themes: [
      {
        id: "light",
        name: "Light",
        tokens: {
          "color-bg": "#ffffff",
          "color-fg": "#111111",
          "color-primary": "#2563eb"
        }
      },
      {
        id: "dark",
        name: "Dark",
        tokens: {
          "color-bg": "#0b1020",
          "color-fg": "#e5e7eb",
          "color-primary": "#60a5fa"
        }
      }
    ]
  }
];

2️⃣ Wrap Your Application

import { ThemeProvider } from "react-tenant-theme";

<ThemeProvider
  tenants={tenants}
  initialTenantId="acme"
  config={{ prefix: "rt" }}
>
  <App />
</ThemeProvider>

3️⃣ Use the Hook

import { useThemeEngine } from "react-tenant-theme";

const { tenant, theme, setTenant, setTheme } = useThemeEngine();

🎨 Styling with CSS Variables

The library generates scoped CSS variables:

body {
  background: var(--rt-color-bg);
  color: var(--rt-color-fg);
}

button {
  background: var(--rt-color-primary);
}

Switching tenant or theme updates all tokens instantly.


🏗 Architecture Overview

react-tenant-theme is structured into three layers:

1️⃣ Tenant Layer

Represents a SaaS customer or brand.

2️⃣ Theme Layer

Represents visual variants (light, dark, brand).

3️⃣ Token Layer

Maps tokens to scoped CSS variables:

color-primary → --rt-color-primary

The runtime engine:

  • Validates tenant/theme relationships
  • Applies tokens safely
  • Persists user preferences
  • Prevents hydration mismatches

⚡ SSR & Hydration Safety

  • Uses an isomorphic layout effect
  • Hydrates before first paint
  • Avoids flash-of-default-theme
  • Safe for Next.js / Vite SSR

💾 Persistence Strategy

Saved to:

localStorage["react-tenant-theme"]

Format:

{
  "tenantId": "acme",
  "themeId": "dark"
}

🧠 Real-World Use Cases

  • White-label SaaS dashboards
  • Enterprise admin panels
  • Multi-brand B2B platforms
  • Internal enterprise tools
  • Client-customizable UI systems

🛣 Roadmap

  • [ ] Configurable storage key
  • [ ] Cookie-based persistence
  • [ ] Pre-hydration inline script
  • [ ] DevTools extension
  • [ ] Tailwind plugin integration
  • [ ] Token validation utilities

🤝 Contributing

Contributions welcome. See GitHub to fork, open issues, or submit PRs.


📄 License

MIT


Built to address real-world multi-tenant theming challenges in scalable React applications.