TenanciTenanci

Help centerIntegrations

FlutterFlow, WeWeb and Softr

How FlutterFlow (and Flutter Web), WeWeb and Softr apps find out which customer they're serving and build the "Connect domain" button without exposing your API key.

FlutterFlow, WeWeb and Softr run in the browser and don't let you read request headers. So in these apps the customer arrives through window.TENANCI, and the portal link is created by a private call (FlutterFlow) or by your backend (WeWeb and Softr). The Integration tab shows every snippet below with your project id already in it.

Before you start

On all three, the app only sees the customer if window.TENANCI is turned on:

  1. Under domain → Settings → Customer for this domain, fill in the Customer id in your app, the Customer data (name, colors…) and turn on Available in the browser (window.TENANCI).
  2. For domains that customers connect through the portal, turn on Send customer data to the browser (window.TENANCI) on domains connected through the portal under project → Customer portal.

FlutterFlow and Flutter Web

Flutter apps draw the screen on a canvas, not in HTML. That has two consequences:

  • TailorKit can't edit elements in a Flutter app. Brand it with the customer data read from window.TENANCI (name, colors, logo from tenant.data);
  • search bots can't see the content without help. Turn on Pre-rendering for bots under domain → SEO → Site so Google and social networks get fully rendered HTML.

Under project → Overview → Single-page app (SPA), choose the Navigation mode (Mask keeps the customer's domain in the address bar) and, if the app needs to open straight on a route, turn on Send the initial route in a variable. More in SPA apps.

Find out who the customer is

  1. Under Custom Code, create a Custom Action named tenanciTenantId that returns String?.
  2. Paste the code below and save.
  3. Call the action in the first page's On Page Load and store the result in an App State.
Custom Action: tenanciTenantId
import 'dart:js_interop';
import 'dart:js_interop_unsafe';
import 'package:flutter/foundation.dart' show kIsWeb;

Future<String?> tenanciTenantId() async {
  if (!kIsWeb) return null;
  final t = globalContext['TENANCI'];
  if (t == null) return null;
  final tenant = (t as JSObject)['tenant'];
  if (tenant == null) return null;
  return ((tenant as JSObject)['id'] as JSString?)?.toDart;
}

"Connect domain" button

  1. Under API Calls, click Add → Import cURL and paste the call below.
  2. Check Make Private: the call now runs on Firebase's server and the key stays out of the app.
  3. Create the tenantId, name and returnUrl variables.
  4. On the button, add a Backend Call action with that call, then Launch URL with the response's url field.
cURL to import
curl -X POST "https://api.tenanci.com/v2/projects/prj_8f3k2m/portal/sessions" \
  -H "Authorization: Bearer tnc_live_xxxxxxxx_xxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{"tenantId":"[tenantId]","tenantData":{"name":"[name]"},"returnUrl":"[returnUrl]"}'

WeWeb

On WeWeb, TailorKit works normally and the customer is read in a formula.

  1. In a formula (for example, on a customerId variable), switch the mode to JavaScript.
  2. Paste the code below.
  3. Use customerId in your collections' filters.
Formula (JavaScript)
return window.TENANCI?.tenant?.id ?? null;

WeWeb doesn't keep secrets on the front end, so the portal link is created by your backend: on Xano, an External API Request with Import cURL; on Supabase, an Edge Function. On the button, call that endpoint in the workflow and use Navigate to with the returned url. Each backend's walkthrough is in Supabase, Xano, n8n and Make.

Softr

TailorKit works normally on Softr (texts, images and colors without code). To show the customer's name in any element:

  1. Go to Settings → Custom code → Header and paste the script below.
  2. On the blocks where the name should appear, add the data-tenanci-name attribute to the element.
Custom code (header)
<script>
  document.addEventListener("DOMContentLoaded", function () {
    var t = window.TENANCI && window.TENANCI.tenant;
    if (!t) return;
    document.querySelectorAll("[data-tenanci-name]").forEach(function (el) { el.textContent = t.data.name || ""; });
  });
</script>

Softr has no backend of its own. For the "Connect domain" button, point the button's link at an n8n or Make webhook that creates the portal link and replies with a redirect to the url. See n8n and Make.

Testing

  • Open the app on the customer's domain. In the editor, in preview and on the platform's own address (*.flutterflow.app, *.weweb-preview.io, *.softr.app) there's no window.TENANCI.
  • In the browser console, type window.TENANCI: you should see { domain, tenant: { id, data } }.
  • Got undefined? Check Available in the browser on the domain (or the portal option) and wait a few seconds after saving.