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

@abdokouta/react-multitenancy

v1.0.0

Published

Multi-tenancy support for Refine with dynamic domain resolution

Downloads

66

Readme

Multi-Tenancy Configuration

Configuration utilities and presets for @pixielity/multitenancy package.

Structure

config/
├── index.ts              # Main exports
├── utils.ts              # defineConfig helper
├── presets/
│   ├── default.preset.ts # Default configuration
│   ├── header.preset.ts  # Header-based configuration
│   ├── subdomain.preset.ts # Subdomain-based configuration
│   └── domain.preset.ts  # Domain-based configuration
└── README.md

Usage

Basic Usage

import { defineConfig, subdomainPreset } from "@pixielity/multitenancy/config";

const config = defineConfig({
  ...subdomainPreset,
  baseDomain: "myapp.com",
  fetchTenants: async () => {
    const response = await fetch("/api/tenants");
    return await response.json();
  }
});

Without Preset

import { defineConfig, TenantMode } from "@pixielity/multitenancy/config";

const config = defineConfig({
  mode: TenantMode.HEADER,
  resolvers: ["subdomain", "router"],
  baseDomain: "myapp.com",
  headerName: "X-Tenant-ID",
  fetchTenants: async () => {
    const response = await fetch("/api/tenants");
    return await response.json();
  }
});

Available Presets

defaultPreset

Simple filter-based with router resolver:

{
  mode: TenantMode.FILTER,
  tenantField: "tenant_id",
  headerName: "X-Tenant-ID",
  queryParam: "tenant_id",
  resolvers: ["router"]
}

headerPreset

Header-based tenant identification:

{
  mode: TenantMode.HEADER,
  tenantField: "tenant_id",
  headerName: "X-Tenant-ID",
  queryParam: "tenant_id",
  resolvers: ["header", "router"]
}

subdomainPreset

Subdomain-based SaaS:

{
  mode: TenantMode.HEADER,
  headerName: "X-Tenant-ID",
  resolvers: ["subdomain", "router"],
  baseDomain: "example.com"
}

domainPreset

Custom domains with dynamic resolution:

{
  mode: TenantMode.HEADER,
  headerName: "X-Tenant-ID",
  resolvers: ["dynamic-domain", "subdomain", "router"],
  baseDomain: "example.com",
  dynamicDomainApiUrl: "/api/tenants/resolve"
}

Configuration Options

Core Options

  • mode: How to pass tenant ID to backend (FILTER, HEADER, URL, QUERY)
  • resolvers: Array of resolver names in priority order
  • fetchTenants: Function to fetch tenants from your API (required)

Resolver Configuration

  • baseDomain: Base domain for subdomain matching
  • pathBasedTenants: Enable path-based tenant resolution
  • dynamicDomainApiUrl: API endpoint for dynamic domain resolution
  • dynamicDomainCacheTTL: Cache TTL for dynamic domain resolver (ms)

Defaults

  • fallback: Fallback tenant ID
  • tenantField: Field name for tenant in filters (default: "tenant_id")
  • headerName: Header name for HEADER mode (default: "X-Tenant-ID")
  • queryParam: Query parameter name for QUERY mode (default: "tenant_id")
  • defaultTenant: Default tenant object

Feature Flags

  • logging: Enable debug logging
  • throwOnMissingTenant: Throw error when tenant resolution fails
  • disableAutoInjection: Disable automatic tenant context injection

Dynamic Tenant Resolution

All tenant data comes from your API dynamically. There are no static mappings.

Fetching Tenants

fetchTenants: async () => {
  const response = await fetch("/api/tenants");
  return await response.json();
}

Dynamic Domain Resolution

{
  resolvers: ["dynamic-domain"],
  dynamicDomainApiUrl: "/api/tenants/resolve",
  dynamicDomainCacheTTL: 600000 // 10 minutes
}

TypeScript Support

Full TypeScript support with comprehensive type definitions:

import type { MultiTenancyOptions } from "@pixielity/multitenancy/config";

const config: Partial<MultiTenancyOptions> = {
  mode: TenantMode.HEADER,
  resolvers: ["subdomain", "router"],
  baseDomain: "myapp.com",
  fetchTenants: async () => {
    const response = await fetch("/api/tenants");
    return await response.json();
  }
};