How to Embed a Supabase Dashboard in Your App

Embed a Supabase dashboard in your app. Connect a read-only role via the session pooler, mirror your RLS tenant rule and mint embed URLs in an Edge Function.

Vivek, Founder of DraxlrVivek12 min read
How to Embed a Supabase Dashboard in Your App

Your support lead pings the engineering channel on a Tuesday.

Support lead: Three customers asked for an orders report this week. One asked twice. Politely. Which is worse.

Engineer: The data's in Supabase. They can already see their orders in the app.

Support lead: One row at a time. They want weekly totals, the pending ones, and a download.

Engineer: So they want a dashboard. I was afraid of that.

That fear is fair. A dashboard request usually turns into a sprint of chart libraries, aggregate endpoints and CSV exports. In June 2026, Supabase's Series F announcement said nearly 10 million developers build on Supabase, and plenty of their apps reach this exact moment.

This guide takes the shorter path. You'll embed a Supabase dashboard in your app with Draxlr and keep each customer to their own rows. A Supabase Edge Function mints the embed URL, so no secret reaches the browser. Already connected Supabase as postgres while following our guide to building a Supabase dashboard? Step 2 shows how to move that connection to a read-only role.

Key takeaways

  • Supabase RLS policies read the user's JWT. A BI connection has none. In our PostgreSQL 18 test, the same policy gave a read-only role 0 of 300 rows, and a role with BYPASSRLS saw all 300.
  • Connect through Supabase's session pooler as a dedicated read-only role, never as postgres.
  • Recreate the tenant rule in Draxlr's row-level security, and send each customer's org ID from an Edge Function.

What you need before you start

  • A Supabase project with your app's tables and a column that identifies the customer, such as org_id.
  • A trusted way to find a user's org. That's a membership table like org_members, or a value in app_metadata.
  • A Draxlr plan. Every plan includes embedding, starting with Premium ($75/month). This guide uses row-level security, which needs Power ($250/month) or above.
  • The Supabase CLI, to deploy one Edge Function. Any backend you already run works too.

How the pieces fit together

Four parts are involved: your frontend, one Edge Function, Draxlr and your Supabase database. The browser never holds a Draxlr secret, and Draxlr never sees your users' Supabase sessions. It only receives the org ID your function vouches for.

Your app (browser) A signed-in user opens Analytics 1. invoke() with the user's JWT Supabase Edge Function Verifies the JWT, finds org_id 42 2. API key + secret, RLS group, orgId 42 Draxlr Returns a short-lived embed URL 3. Embed URL, via function 4. Queries as analytics_ro, org_id = 42 added Supabase Postgres Session pooler, port 5432
The Edge Function is the only place that knows both who the user is and the Draxlr API secret.

Do your Supabase RLS policies protect an embedded dashboard?

Not on their own. The postgres role "has bypassrls", according to Supabase's Row Level Security guide, so a BI tool connected as postgres sees every customer's rows. A dedicated role sees nothing. The policies apply only to the authenticated role and read the user from a JWT, and a BI connection has neither.

Your policies probably look like this:

create policy "members read own org orders" on orders
  for select to authenticated
  using (org_id in (select org_id from org_members where user_id = auth.uid()));

We tested this on a throwaway PostgreSQL 18.3 cluster. It used the auth.uid() function from Supabase's auth repository, the policy above, and 300 orders split evenly across three orgs.

Connected as Stands in for Rows returned
A role with BYPASSRLS Supabase's postgres role 300 of 300, every org
A read-only login role A BI connection 0 of 300, and auth.uid() returned NULL
The authenticated role with an org 1 member's claims A request from your app 100 of 300, org 1 only

The fix is to give the dashboard its own copy of the tenant rule, keyed on the same org_id column, while your app keeps its policies.


Step 1: Create a read-only role for Draxlr

Supabase's roles guide says you should never give the postgres password to a third-party service "unless you absolutely trust them". It recommends a separate user for every service. Here's that role for a dashboard, run in the Supabase SQL editor:

create role analytics_ro with login password 'use-a-long-random-password';
grant usage on schema public to analytics_ro;
grant select on public.orders, public.plans to analytics_ro;

-- Your app's policies don't cover this role, so allow reads explicitly
create policy "analytics_ro reads orders" on public.orders
  for select to analytics_ro using (true);
create policy "analytics_ro reads plans" on public.plans
  for select to analytics_ro using (true);

-- Cancel runaway dashboard queries
alter role analytics_ro set statement_timeout = '15s';

Grant only the tables the dashboard needs, and add a table the same way when the dashboard grows. Leave out anything holding tokens, secrets or personal notes. The role reads every org's rows in those tables on purpose, and Draxlr's row-level security narrows them per customer in Step 4. Generate the password in a password manager, and delete the SQL snippet once it has run.

In the same test cluster, analytics_ro read all 300 rows once its policy existed, while app users stayed limited to their own org. Inserts and deletes failed with "permission denied". A 5-second query was cancelled under a 3-second timeout. For reference, Supabase's timeouts guide lists defaults of 3s for anon and 8s for authenticated.


Step 2: Connect Supabase to Draxlr

Supabase's connection guide recommends the shared pooler in session mode for "a third-party tool, such as a BI client or database GUI". It's reachable over IPv4 and supports prepared statements. The direct connection is IPv6 unless you buy the IPv4 add-on.

In Draxlr:

  1. Add a database, choose Supabase and click Connect Supabase.
  2. Sign in on supabase.com, approve access, and pick your project.
  3. Draxlr fills in the shared pooler host, port, database name and a postgres.<project-ref> user. Check that the port is 5432, which is session mode. If it shows 6543, change it to 5432.
  4. Change the user to analytics_ro.<project-ref>. Supabase's docs say a custom role on the shared pooler uses [ROLE].[PROJECT-REF] as the username.
  5. Enter the role's password. That's the database password you set in Step 1, not your Supabase account password.

Already connected as postgres? Edit that connection and swap in the new user and password. If you turned on Network Restrictions in Supabase, add the Draxlr IP address shown on the form to your allowed list. Draxlr is also listed in Supabase's partner catalog.

Expect heavy dashboards or lots of viewers? Point Draxlr at a read replica instead. Read replicas need the Pro, Team or Enterprise plan and at least a Small compute add-on, per Supabase's read replica guide. Each replica has its own connection string.


Step 3: Build the dashboard

Build each item one of three ways:

  • Query builder for picking tables, filters and groupings without SQL
  • AI for describing a question in plain English and reviewing the query it writes
  • SQL editor for full control over joins and Postgres functions

A useful first version for an orders product has four to six items. Start with an "Orders this month" metric, a weekly orders trend customers can drill into, a pending orders table and revenue by plan as a pivot. Each item runs against live Supabase data when a customer opens it, so more items mean more queries per page load.

Two habits make Step 4 easier. Keep the org_id column on every customer-data table you use, because the row rule applies per table. In SQL editor items, start from the tenant-scoped table and use INNER or LEFT joins, so the rule filters the rows you start from.


Step 4: Mirror your Supabase tenant rule with Draxlr RLS

Draxlr's row-level security for embeds carries the same rule over in three parts. It's available on the Power plan and above.

  • A permission lists the tables the embed can use and adds a row rule to each one, here org_id equals the orgId attribute. Shared lookup tables, like a list of plans, can be allowed without a rule.
  • An RLS group, say Customers, attaches that permission.
  • The embed token names the group and carries the customer's orgId. Your backend adds both when it requests the embed URL.

Compare that with the Supabase policy above. The rule org_id = <value> stays the same. What moves is the lookup: "which org is this user in?" now runs in your Edge Function. Your function sends the answer as an attribute, and Draxlr signs it into the embed token. Draxlr then adds the rule to the queries behind the embed, including filters, drill-downs and exports. Tables outside the permission are blocked.

If org_id is a uuid, send it as a string. Before you ship, open Row-level security in Draxlr's embed builder, enter a real org ID and preview what that customer sees.

Where should the org ID come from? Use the membership table or app_metadata. Never use user_metadata. Supabase's user data guide warns that "users can edit their own user metadata, so a role or tenant ID stored there lets a user grant themselves access."


Step 5: Mint the embed URL in a Supabase Edge Function

First, store the Draxlr values as Edge Function secrets:

supabase secrets set DRAXLR_API_KEY=... DRAXLR_API_SECRET=... DRAXLR_DASHBOARD_ID=...

Then create supabase/functions/analytics-embed/index.ts. It uses the withSupabase wrapper from Supabase's Edge Function auth guide, which checks the caller's JWT. Per the @supabase/server README, it also handles CORS. The request body follows Draxlr's Generate Embed URL API:

import { withSupabase } from 'npm:@supabase/server@1'

const DRAXLR_API = 'https://api.draxlr.com/api/dashboardGroup/generate-embed-url/'

export default {
  fetch: withSupabase({ auth: 'user' }, async (req, ctx) => {
    const { orgId } = await req.json().catch(() => ({}))
    if (!orgId) return new Response('orgId required', { status: 400 })

    // ctx.supabase runs as the signed-in user, so your own
    // RLS policy limits this lookup to their membership rows
    const { data: member, error: lookupError } = await ctx.supabase
      .from('org_members')
      .select('org_id')
      .eq('user_id', ctx.userClaims!.id)
      .eq('org_id', orgId)
      .maybeSingle()
    if (lookupError) return new Response(lookupError.message, { status: 500 })
    if (!member) return new Response('Not a member of this org', { status: 403 })

    const res = await fetch(DRAXLR_API + Deno.env.get('DRAXLR_DASHBOARD_ID'), {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        apiKey: Deno.env.get('DRAXLR_API_KEY'),
        apiSecret: Deno.env.get('DRAXLR_API_SECRET'),
        embedOptions: {
          rlsGroup: 'Customers',
          attributes: { orgId: member.org_id },
        },
      }),
    })
    const { success, embedUrl, error } = await res.json()
    if (!success) return new Response(error ?? 'Embed failed', { status: 502 })
    return Response.json({ embedUrl })
  }),
}

Deploy it with supabase functions deploy analytics-embed. Keep the default verify_jwt = true, so Supabase checks the token before your code runs.

Your app sends the active org ID, and the function checks membership before calling Draxlr. That works for users in one org or several, and changing orgId in the browser gets a 403, not another org's dashboard. To set the theme, header or exports, copy the configuration object from Draxlr's embed settings into embedOptions.

One catch: @supabase/server only accepts Supabase's newer JWT signing keys and API keys. If your project still signs user tokens with the legacy JWT secret, migrate to JWT signing keys first, or verify the caller with supabase-js auth.getUser() instead.


Step 6: Render the dashboard in your frontend

Draxlr offers HTML, React and Vue embed code. In the browser, supabase.functions.invoke sends the signed-in user's session token for you. Here's the HTML version, which adds the embed after the URL arrives:

const { data, error } = await supabase.functions.invoke('analytics-embed', {
  body: { orgId: activeOrgId },
})
if (error) throw error

const embed = document.createElement('div')
embed.className = 'draxlr-embed'
embed.dataset.id = 'YOUR_DASHBOARD_ID'
embed.dataset.embedurl = data.embedUrl
embed.dataset.width = '100%'
embed.dataset.minheight = '600px'
embed.dataset.maxheight = '2000px'
document.getElementById('analytics').append(embed)

const script = document.createElement('script')
script.src = 'https://assets.draxlr.com/embed/embed-v2b.js'
document.body.append(script)

Use the same dashboard ID here and in DRAXLR_DASHBOARD_ID, because the script matches height updates by data-id. Load the script once per page. In a single-page app where the analytics view mounts more than once, use the React or Vue component instead. Pass the same URL as the embedUrl prop, and the component reloads when that prop changes.

Draxlr single dashboard embed preview with a KPI, a line chart, a pivot table and a bar chart, next to the Embed Settings panel with row-level security, filters, drill-down, exports and appearance options

Appearance follows your background color. Draxlr picks the light or dark theme from it, so use a six-digit hex value such as #ffffff. If your app has both themes, request a URL for each. Our guide to embedding a dashboard in dark and light mode covers the switch.


Before you launch

  • Role check. Run select current_user in Draxlr's SQL editor. It should return analytics_ro, not postgres.
  • Two test orgs. Request a URL for each and compare every item, including after filters and drill-downs.
  • Table list. The permission covers only the tables the dashboard needs.
  • Secrets. The Draxlr API secret exists only in Edge Function secrets. Search your frontend build for it to be sure.
  • Load. statement_timeout is set on the role, and big dashboards point at a read replica.
  • Allowed domains. The embed settings list only your app's domains.

Want customers to build their own reports?

A fixed dashboard answers the questions you predicted. When customers start asking for their own cuts of the data, look at full app embedding on the Power plan. Each customer gets a separate analytics workspace in your product, with shared dashboards, their own dashboards and saved queries, a query builder, a SQL editor and an AI assistant.

The Supabase side doesn't change. The same Edge Function sends the RLS group and orgId, plus a user identifier, to Draxlr's full app embed API, and your frontend loads it with an HTML snippet. We compare the two approaches in single dashboard vs full app embedding.


Conclusion

Embedding a Supabase dashboard comes down to one idea: your app's RLS policies stay where they are, and the dashboard gets its own copy of the tenant rule.

  • Connect through the session pooler as a read-only role with a timeout.
  • Build the dashboard once from tables, metrics and charts.
  • Mirror org_id in Draxlr's row-level security.
  • Let an Edge Function vouch for the user's org and keep the API secret.

For the Postgres version of this setup, see how to embed a PostgreSQL dashboard. To compare plans and features, start with Draxlr for Supabase and the embedded analytics tool overview.

Connect your Supabase database

FAQs

1. Can I embed a Supabase dashboard in my app?

Yes. Connect your Supabase database to an embedded analytics tool, build the dashboard and add the embed code to your app. Draxlr offers HTML, React and Vue embed code, plus a backend API that generates a signed embed URL for each customer.

2. Do Supabase RLS policies apply to an embedded dashboard?

Not directly. Policies built on auth.uid() need the user's JWT, which a BI connection doesn't send. In our test, a read-only role saw 0 of 300 rows and a role with BYPASSRLS saw all 300. Recreate the tenant rule in the analytics tool instead.

3. Which Supabase connection should a BI tool use?

Supabase recommends the shared pooler in session mode for third-party BI tools. It's reachable over IPv4 and supports prepared statements. Connect as a dedicated read-only role, using the username format role.project-ref, instead of the postgres role.

4. How do I show each customer only their own data?

Use row-level security in the analytics layer. In Draxlr, create a permission with a rule such as org_id equals orgId and attach it to an RLS group. Your backend sends the group and the customer's orgId when it requests the embed URL.

5. Can a Supabase Edge Function generate the embed URL?

Yes. The function verifies the caller's Supabase JWT, checks that they belong to the org your app sent, and calls Draxlr's generate-embed-url API with the API key and secret stored as Edge Function secrets. It returns only the embed URL, so the secret never reaches the browser.

About the author

Vivek, Founder of Draxlr

Vivek is a coder and the founder of Draxlr who cares deeply about building good products. He works at the intersection of AI, SQL, dashboards, and embedded analytics, with a strong focus on making complex data workflows feel simple, useful, and fast for real teams.

If you have questions about anything in this guide, or want to compare options for your specific stack, you can email Vivek at vivek@draxlr.com, try Draxlr free, or reach out directly through the Draxlr team.

Related Blogs

Start free today

Every piece of your analytics, in one place.

Connect your database and the rest falls into place. Your first dashboard is minutes away.

No credit card required

This website uses cookies to ensure you get the best experience.