Search code examples
javascriptreactjsreduxarchitecturemulti-tenant

Handle Multi-Tenant React application


Basically i have a multitenant react app. I have currently 15 customers, which is deployed to Dev, Stage and Prod Env's. I am having different requirements for different customers irrespective of Dev, stage and Prod. what is best practice to maintain this architecture. Currently I am having conditions writing inside my code for specific customers to have that specific change.

I am using React 15.6.1, WebPack, Redux

enter image description here

Below is my configuration file

appConfig = {
    localhost: {
      param1: 'customer-det',
      param2: 'customer-det',
      param3: 'customer-det',
    },
    'Customer1': {
      param1: 'customer-det',
      param2: 'customer-det',
      param3: 'customer-det',
    },
    'Customer2': {
      param1: 'customer-det',
      param2: 'customer-det',
      param3: 'customer-det',
    },
    'Customer3': {
      param1: 'customer-det',
      param2: 'customer-det',
      param3: 'customer-det',
    },
    'Customer4': {
      param1: 'customer-det',
      param2: 'customer-det',
      param3: 'customer-det',
    },
    'Customer5': {
      param1: 'customer-det',
      param2: 'customer-det',
      param3: 'customer-det',
    },
  };

Solution

  • IMHO, the notion of identifying the tenant's within the code and rendering the content based on the tenant parameters is not a very flexible and scalable option.

    Consider the following options

    1. Single code base with Extension fields and dynamic UI rendering, this helps each tenant to add custom fields to a base entity and see them in the UI.

    2. Having modules and licensing per tenant: In this model, you can build various modules in the application and then package them, each tenant will have a license that decides whether the module is accessible to a given tenant.

    This will be very helpful for you to build new features, bill your tenants, track the usage and lots of benefits.

    The above option requires more thought process and might require rewriting some or most of the current code base. However, the benefits you can reap will be high in-terms of flexibility, scalability, monetary gains etc...

    HTH