Help centerIntegrations
Lovable, Bolt and other AI builders
Turn an app built with Lovable, Bolt or another AI builder into a white-label app with a ready-made prompt, a Supabase Edge Function and window.TENANCI.
Apps built with AI usually start out serving a single customer. With Tenanci, the same app serves many customers, each on their own domain, and the builder itself writes the code changes: you paste a ready-made prompt into the Lovable or Bolt chat, and it adds the customer lookup, the backend function and the "Connect my domain" button.
How it works
The app (React/Vite) stays hosted where it is. Tenanci hands each domain's customer to the browser in
window.TENANCI, and the "Connect my domain" button calls a Supabase Edge Function that creates a
customer portal link. The Tenanci key lives only in Supabase.
TailorKit works normally on React/Vite apps, so each customer's texts, colors and images can also be adjusted without code.
Before you start
- Under domain → Settings → Customer for this domain, fill in the Customer id in your app, the Customer data and turn on Available in the browser (window.TENANCI).
- Under project → Customer portal, turn the portal on, along with Send customer data to the browser (window.TENANCI) on domains connected through the portal.
- Under API keys, create a key with the
domains:writescope, restricted to the project. - In the app's Supabase, store the key as the
TENANCI_API_KEYsecret (Edge Functions → Secrets, orsupabase secrets set TENANCI_API_KEY=...).
Ready-made prompt
- Open project → Integration and pick Lovable or Bolt (Tenanci usually detects it on its own from the
*.lovable.appor*.bolt.hostaddress). - In the Ready-made AI prompt box, click copy.
- Paste it into the builder's chat and review the changes before publishing.
The prompt already includes your project id and the API address. In English, it reads:
This app will serve many customers, each on their own domain, through Tenanci (a white-label proxy). In Lovable:
1. On load, read window.TENANCI (it may not exist in development): { domain, tenant: { id, data } }. Use tenant.data.name and the other tenant.data fields to show the customer's branding, and use tenant.id to know which customer is being served. Without window.TENANCI, keep the default behavior.
2. Create a backend function (Supabase Edge Function "tenanci-portal") that, for the logged-in user, calls POST https://api.tenanci.com/v2/projects/prj_8f3k2m/portal/sessions with the header Authorization: Bearer <secret TENANCI_API_KEY> and the JSON body { "tenantId": <the logged-in user's customer id>, "tenantData": { "name": <customer name> }, "returnUrl": <current app URL> } and returns the response JSON ("url" field). Validate the user through the session; never accept a tenantId coming from the browser and never expose the key on the front end.
3. On the settings screen, add a "Connect my domain" button that calls this function and opens the returned "url" in the same tab.Find out who the customer is
If you'd rather do it by hand, this is the lookup in React:
const t = window.TENANCI; // { domain, tenant: { id, data } } — missing outside customer domains
const customerId = t?.tenant?.id ?? null;
const name = t?.tenant?.data?.name ?? "My app";Use name and the other tenant.data fields for branding, and customerId to filter what's shown. Remember that
everything in window.TENANCI is public: for permissions, rely on the user's Supabase session.
The Edge Function
It's the same function the prompt asks for. Create it at supabase/functions/tenanci-portal/index.ts and deploy
with supabase functions deploy tenanci-portal. The full code, with your project id, is on the Integration tab
and in Supabase, Xano, n8n and Make.
On the front end, the button just calls the function and opens the url:
const { data, error } = await supabase.functions.invoke("tenanci-portal");
if (!error && data?.url) window.location.href = data.url;Performance and SEO
- HTML cache (domain → Settings → Performance): in single-page apps, the HTML is the same for every visitor. Pick 1 minute, 5 minutes or 1 hour so the edge answers instantly, even when hosting is slow. Don't use it if the HTML is built with the logged-in user's data.
- Pre-rendering for bots (domain → SEO → Site, Growth and Scale plans): Google and social networks get the fully rendered page, with the customer's title and description.
More about single-page apps in SPA apps.
Other builders
Replit, Cursor, v0 and the like follow the same path: under App platform, choose Other (React, Vue, Next…). The generic guide also has a Ready-made AI prompt, plus the cURL call and an SDK example for apps with their own backend. If your AI agent speaks MCP, it can also add domains and create portal links straight through Tenanci: see AI agents (MCP).

