To add login to a vibe coded app, ask your platform to add authentication, tell it which pages need sign-in, and then lock down the database so each user only sees their own data. That last step is the one people skip, and it's the one that matters most.
Login is two jobs, not one
Supabase's Auth docs separate the two clearly. Authentication confirms someone is who they say they are. Authorization decides what they're allowed to access.
AI tools are good at the first job: a sign-up form, a login page, a log-out button. The second job lives in your database rules, and it's invisible from the screens. Lovable's authentication docs say it directly: sign-in identifies a person but doesn't limit what they can access. Row level security policies do that.
Step 1: Decide what's private
Before you prompt, list it out:
- Which pages need a logged-in user?
- What data belongs to one user only?
- Are there roles, like admin and member?
- Which actions are sensitive, like changing an email or seeing payment details?
Step 2: Add login to your vibe coded app
On Lovable
Ask in the chat and name the protected pages. Lovable's docs say that if you don't name methods, it sets up email and password sign-in, Google sign-in and Sign in with Lovable. It also supports Apple, Microsoft, phone (with your own SMS provider) and company sign-in through SAML or OIDC. Authentication requires its built-in backend. For sensitive actions, Lovable suggests asking for a session check that stops the action if the session has ended.
On Bolt
Bolt's Supabase docs say asking Bolt to add Supabase auth creates sign-up and login, and new users appear under Authentication, Users in your Supabase dashboard.
With Supabase Auth anywhere
Supabase Auth supports password, magic link, one-time password, social sign-in and single sign-on, with providers including Apple, GitHub, Google and Microsoft, per its docs. It works with any tool that writes code, including Cursor and Claude Code.
A prompt that covers the basics:
Add sign-up and login with email and password. Require login for the dashboard and settings pages, and send logged-out visitors to the login page. Each user should only see their own notes. Add a log-out button in the header.
Step 3: Set redirect URLs
Sign-in providers send users back to your app after they log in, and they only send them to addresses you've approved. Lovable's docs say that if sign-in works in preview but fails on your published app or custom domain, a redirect URL is usually missing. For addresses outside Lovable, you add them yourself under Settings, Advanced. If you use your own Google credentials, you also add the redirect URI in Google Cloud Console.
Step 4: Lock down the data
If your app uses Supabase, this means row level security. Supabase's RLS docs say RLS must be enabled on every table in an exposed schema, and that with RLS on and no policies, no rows are accessible through the API with a publishable key.
A policy that lets users read only their own rows looks like this, 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 );
You'd add similar policies for insert, update and delete. Supabase recommends separate policies per operation. One warning from the same page: don't add an or auth.uid() is null branch to a policy, because that returns every row to requests with no user.
You don't have to write SQL yourself. Ask the AI to add RLS policies, then check them in the Supabase dashboard. Vibe coding with Supabase goes deeper.
Step 5: Test like an attacker
Lovable's best practices recommend testing with two accounts to confirm privacy, and re-running that test after any change to data or roles. Here's a short routine:
- Log out and open every private page directly by its URL. Each should send you to login.
- Create user A and add some data. Log in as user B in a private window. B shouldn't see A's data.
- As B, change an ID in the URL to one of A's records. You should get nothing.
- Try submitting a form after logging out in another tab.
If any step leaks data, the problem is in the database rules, not the login page.
Keys and tokens
- Supabase's publishable key is meant for front-end code. Its secret key bypasses RLS and must never be in a browser, per Supabase's API key docs.
- Never paste keys into the AI chat. Use your platform's secrets form.
- Lovable notes that signing out ends a session, but an access token already issued keeps working until it expires. Keep token-protected actions on the server side.
Common mistakes
- Hiding a button instead of protecting the data. A hidden admin button doesn't stop anyone calling the API.
- Adding login too early. Lovable suggests adding sign-in only when you need per-user data.
- Trusting the preview. Test on the published domain too.
Our security checklist has more to check before launch, and security basics are one of the criteria in our platform comparison.