Skip to main content

Vibe Coding With Supabase: Setup and Security Checklist

· By Natalie Walls

Vibe coding with Supabase means letting your AI tool use Supabase as the back end: a Postgres database, user logins, file storage and server functions. Lovable and Bolt both connect to it, and any code editor can use it. The one thing you must get right is row level security, because without it your database may be open to anyone who has your app's public key.

What Supabase gives a vibe coded app

  • Database. Postgres tables for your data.
  • Auth. Sign-up and login with password, magic link, one-time password, social providers and SSO, per Supabase's Auth docs.
  • Edge functions. Server code for things like payments, email and AI calls.
  • Storage. Buckets for uploaded files.

Using Supabase with Lovable

Lovable's default back end is Lovable Cloud, but you can connect your own Supabase project. Lovable's Supabase docs say:

  • A workspace owner or admin links a Supabase organization once. Then editors can connect projects.
  • Lovable designs tables from plain-language descriptions and runs them as migrations saved in your project under supabase/migrations/.
  • Secrets you enter go into Supabase, and Lovable doesn't read them back.
  • Some features only work on Lovable Cloud, such as managed Google auth and SAML SSO.
  • There's no automatic migration between Lovable Cloud and Supabase in either direction, so pick early.

Lovable runs automated checks for RLS coverage, but its docs still tell you to verify every table's policies yourself in the Supabase dashboard before going live.

Using Supabase with Bolt

Bolt's Supabase docs say Supabase is an alternative to the default Bolt Database, available on Pro and Teams plans. You connect once in account settings, and you can't change the authorized Supabase organization later. Server functions run as Supabase edge functions that Bolt deploys for you. Two notes from Bolt: on Supabase's Free plan, databases pause after a week of low activity, even for published projects, and restoring an earlier Bolt version doesn't change your Supabase data.

Know your keys

Supabase's API key docs describe two kinds:

KeyStarts withWhere it goes
Publishable (older: anon)sb_publishable_Browser and mobile code is fine
Secret (older: service_role)sb_secret_Server only. Never in a browser

The secret key bypasses every RLS policy. Supabase says never to put it in a web page, a shipped app or source control, and never to send it over chat or email. If it leaks, rotate it.

The publishable key is public by design. That's fine only because RLS decides what it can reach. Supabase says that to rely on RLS, you need to enable it on all tables and review the policies regularly.

Turn on row level security

Supabase's RLS docs explain that a policy works like a filter Postgres adds to every query. Three facts from that page matter most:

  1. RLS must be enabled on every table in an exposed schema.
  2. With RLS on and no policies, nothing is readable through the API with a publishable key.
  3. auth.uid() returns the ID of the signed-in user, and it's null for logged-out requests.

Here's the shape of a policy that lets users read only their own rows, adapted from Supabase's example:

alter table public.notes enable row level security;

create policy "Users can read own notes"
on public.notes
for select
to authenticated
using ( (select auth.uid()) = owner_id );

Supabase suggests separate policies for select, insert, update and delete, and always naming the role with to. It warns against adding or auth.uid() is null to a policy, because that returns every row to logged-out requests. For speed, it recommends wrapping auth.uid() in a select as shown, and indexing the column the policy filters on.

You can ask your AI tool to write these:

Enable row level security on every table. Add policies so signed-in users can only select, insert, update and delete their own rows, matched on owner_id. Show me the SQL before applying it.

Test the rules, not the screens

The app's screens can look perfect while the database is wide open. Test the data layer:

  1. Create two accounts and add data with each. Neither should see the other's.
  2. Log out and confirm private data doesn't load.
  3. Check the Supabase dashboard for any table with RLS off.

Lovable's best practices recommend re-running the two-user test after any change to data or roles.

Vibe coding with Supabase: a checklist

  • RLS is on for every table.
  • Every table has policies for each operation it needs.
  • Only the publishable key appears in front-end code.
  • The secret key lives only in server functions or platform secrets.
  • You've tested with two accounts and logged out.
  • You know whether your plan pauses inactive databases.

For the login side, see how to add login to a vibe coded app. Payments usually run in Supabase edge functions too; see how to add payments. And our security checklist covers the rest.

Security basics are one of the five criteria in our platform comparison.