How to Integrate Hex and Supabase Safely

Published
Length
3 min read

Luis Felipe Dias

All posts

Integrating hex and supabase lets data teams run live SQL queries and build notebooks against production Postgres data. You link the two tools by creating a dedicated database role in Supabase and adding those credentials to Hex. This setup helps analysts explore app data and share charts with the rest of the company. Still, linking an analytics tool to a live database brings real security risks. If you use the default admin password, anyone in the workspace can change or delete production tabl

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Integrating hex and supabase lets data teams run live SQL queries and build notebooks against production Postgres data. You link the two tools by creating a dedicated database role in Supabase and adding those credentials to Hex.

This setup helps analysts explore app data and share charts with the rest of the company. Still, linking an analytics tool to a live database brings real security risks. If you use the default admin password, anyone in the workspace can change or delete production tables. A safe setup needs strict role limits, network controls, and clear query logs.

How hex and supabase work together

Supabase gives every project a full Postgres database. Hex acts as a collaborative workspace where teams write SQL and Python to study that data. When an analyst runs a cell in Hex, Hex opens a database session to Supabase and sends the query.

Every Supabase project starts with a default postgres role that holds admin rights. Supabase does not grant true superuser rights because those allow destructive actions on the database. Even so, the default postgres role has extra rights for high-level tasks. The password you set when creating your project belongs to this default admin role.

Supabase warns that you should never give this main password to an outside service. Instead, you should make a fresh database user for each external tool. When you set up Hex, you create a dedicated Postgres role in Supabase first. Then you grant that role read-only rights on the specific schemas and tables your analysts need.

Supabase also includes built-in roles like anon, authenticated, service_role, and authenticator for app traffic. You should not use these app roles for your analytics workspace. A separate role for Hex keeps your notebook queries distinct from your main app traffic.

Common failure modes and how to scope roles

The most common mistake is pasting the main postgres role password into a shared Hex data source. When you do this, every person who can query that data source gets admin rights. A bad query can drop a table, lock rows, or slow down your live app.

End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Shared service accounts also ruin your audit logs. When ten analysts run queries through one shared database user, the database logs show every query coming from the same account. You cannot tell which person ran an expensive query or pulled sensitive rows. By contrast, queries run inside the Supabase dashboard run as the postgres role and include a source comment.

Another risk is exposing sensitive user columns to every notebook user. Customer tables often hold emails, phone numbers, card numbers, or national IDs. If your Hex role can read the whole table, any notebook query can pull those fields into memory. To reduce this risk, grant your Hex role access only to safe tables or specific columns.

You should also lock down how the two systems talk over the network. Do not leave your database open to every address on the public web. Restrict inbound traffic so only known addresses from your analytics workspace can reach the database port. Finally, set query timeouts on the Hex role so a runaway join cannot starve your production app.

Check every Postgres query on the wire

Database roles and network rules decide who can open a session. They do not read what each SQL statement does after login. With hoop.dev, you run an open-source proxy, a sidecar for your Postgres. It runs beside your database and reads the Postgres wire protocol. Your apps and agents keep their login details and change only the host and port in the connection string their tool uses.

Before a query runs, hoop.dev guardrails check the statement by its effect, table, or pattern. They refuse bad deletes or drops with a real Postgres error. On the way back, hoop.dev data masking rewrites sensitive values in returned rows based on your rules. Every query and verdict goes to the audit trail. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and generates evidence for HIPAA, GDPR, and PCI DSS. See the code on GitHub.

Frequently asked questions

No, you should never share the default postgres role password with an outside tool unless you have no other choice. Supabase recommends creating a separate database user for every external service so you can limit its rights and revoke it anytime.

How do I stop Hex users from changing data in Supabase?

Create a dedicated Postgres user for Hex and grant it select rights only on the tables your team needs. Do not grant insert, update, delete, or schema change rights to this analytics role.

How can I protect sensitive columns like emails and phone numbers in Hex queries?

You can restrict the Hex database role to read only specific columns or safe database views that exclude sensitive fields. You can also use data masking rules that rewrite matched fields like emails, phone numbers, and card numbers in query results.

The query runs. The emails stay hidden.