Back to Blog

How to prevent duplicate accounts with Supabase Auth

What Supabase Auth covers on duplicate accounts, the signup hooks people add next, where each one breaks and what to set up this week.

Six days ago you shipped the fix, and you were pleased with it. One Postgres function, wired into Supabase Auth's Before User Created hook, refusing every signup from a list of 4,000 throwaway email domains. You turned on Confirm email the same afternoon and posted the hook's log in your team chat. For the first time in weeks you stopped opening the users table before breakfast.

It's 8:17 a.m. on the 9th. Your model provider has emailed you an invoice for $3,200, which is the limit you set for the whole month and never expected to touch. It was reached at 5:48 a.m., so your product has been returning errors to everyone for 149 minutes. At 7:02 a customer on your $39 plan wrote: "Everything's failing and we publish at 9. Should we be looking for another tool?"

This is a scenario, so swap in your own numbers, but follow the arithmetic. Your paying customers use about $55 of model time a day. Each new account gets 50 free generations at $0.06 each, or $3.00.

8 days x $55          = $440 of real usage
$3,200 - $440         = $2,760 you can't explain
$2,760 / $3.00        = 920 accounts, fully used
920 x 50 generations  = 46,000 generations

You open the users table. There are 1,100 new users in six days, where your normal 30 a day would make 180. That leaves 920, all with confirmed emails. Your hook's log says it refused 63 signups, and that's true. The Supabase Auth duplicate accounts you actually have came in on addresses that aren't on any list.

So you check the bill you assumed would show this, and Supabase's hasn't moved. Its Pro plan includes 100,000 monthly active users, and even past that, 920 more would be $2.99 (920 × $0.00325). Your model provider charged you $2,760 for the same accounts.

Follow it down. $2,760 in six days is $460 a day, or $13,800 over 30 days. All 120 of your paying customers together pay $4,680 a month (120 × $39), so you're on pace to spend about three times your revenue on people who'll never pay. You had $38,000 in the bank and $9,500 of net burn, which was four months. Add $13,800 and it's $38,000 ÷ $23,300, or about seven weeks.

By 9 a.m. there are 14 refund requests, another $546 (14 × $39), and the customer who publishes at 9 has stopped replying. You have to decide something before lunch. Raise the limit and you keep paying for those accounts. Leave it and your customers stay locked out. Cut free credits from 50 to 10 and a first-time user may never reach a good result, on the free plan that brought you almost all of those 120 customers.

Why Supabase Auth doesn't stop duplicate accounts

Supabase Auth answers the question it was built for, which is who's signing in, and it handles the email side well. It links identities that share an email address to one user, so a password signup and a later social login end up as one account, and it skips that link when the email is unverified. With Confirm email on, people must confirm their address before their first sign-in.

All of that is about one email address, and one person can have plenty of them. To Supabase, sam@one.example and sam@two.example are two users, which is correct. The question your product needs answered comes later and it's about a human being: has this person already had the free credits? An auth system has no reason to know.

So you write your own rules. The Before User Created hook runs just before a new user is inserted. It receives the proposed user and the IP address, and it can refuse the signup with a message that goes back to the client. It's available on the Free and Pro plans. A Postgres hook gets 2 seconds to finish, and an HTTP hook gets 5.

[Not on the list]alt[On the list]Signs up with an emailProposed user and IPDomain on your list?Error and messageSignup refusedEmpty responsePlease confirm your emailConfirmsSpends 50 free creditsNew signupSupabase AuthYour hookYour appNew signupSupabase AuthYour hookYour app
[Not on the list]alt[On the list]Signs upwith anemailProposeduser andIPDomainonyourlist?ErrorandmessageSignuprefusedEmptyresponsePleaseconfirmyouremailConfirmsSpends 50 free creditsNewsignupSupabaseAuthYourhookYourappNewsignupSupabaseAuthYourhookYourapp

This is the basic version from the opening:

hook_before_user_created.sql
create or replace function public.hook_before_user_created(event jsonb)
returns jsonb
language plpgsql
as $$
declare
  email_domain text := lower(split_part(event->'user'->>'email', '@', 2));
begin
  if exists (
    select 1 from public.blocked_email_domains where domain = email_domain
  ) then
    return jsonb_build_object('error', jsonb_build_object(
      'http_code', 403,
      'message', 'Please sign up with a different email address.'
    ));
  end if;
  return '{}'::jsonb;
end;
$$;

grant select on public.blocked_email_domains to supabase_auth_admin;
grant execute on function public.hook_before_user_created to supabase_auth_admin;
revoke execute on function public.hook_before_user_created
  from authenticated, anon, public;

It assumes a blocked_email_domains table of your own. Enable it in your project's Auth Hooks settings.

Where the basic Supabase signup hooks break

Each of these catches something real. Add the ones worth their upkeep.

Confirm email and unique addresses

Keep both. They catch typos, dead addresses and the same address twice. They miss anyone with a second real inbox, because a confirmed email only proves someone can open that inbox. They can shut out people whose confirmation lands in spam. You'll need your own email sender too, since Supabase's built-in one allows 2 emails an hour for the whole project.

Blocking disposable domains

The rule above catches known throwaway services, as of the day the list was updated. It misses tomorrow's new domain and every ordinary mailbox, which is how 920 accounts got past a list of 4,000. It also turns away people using privacy forwarding, and some of them were going to pay you. And someone has to maintain that list forever, so decide whether it's worth it.

Gmail dots and plus addressing

Gmail ignores dots in personal addresses, so jane.doe@gmail.com and janedoe@gmail.com reach one inbox, and a plus sign and a word before the @ land there too. That's how email works. Nothing in Supabase's docs says it treats those spellings as one address, so test yours. A rule for this catches one inbox written several ways and misses a second real mailbox. It also needs upkeep, so now you keep rules per provider.

One signup per IP address

The hook gets the IP address, so this one's tempting. It catches repeat signups from one connection and misses every signup from any other network. It also refuses offices, campuses and households. The morning your best customer's team of 12 signs up from the office, 11 of them see your error message, and you get the tickets.

The rest of the usual list

Basic fixWhat it catchesWhat it missesWho it wrongly blocksWhat it costs to keep working
CAPTCHA, built into Supabase AuthSimple scriptsPeople signing up by handPeople using screen readers or privacy toolsLost signups
Phone requirementCasual second accountsAnyone with another numberPeople without a reliable mobile numberA charge for every text
Card requirementCasual second accountsAnyone with another cardStudents and people who want to try firstFar fewer signups
VPN blocksKnown VPN rangesEverything off your listStaff on company VPNsAnother list to maintain
Supabase's default rate limitBursts from one addressAbout 6 signups an hourReal users in a busy hourTuning
Usage caps per accountOne account overrunningEach new account's fresh capAnyone at the capDeciding when your product stops
Fewer credits, shorter trialsSome cost per accountMore accounts fill the gapEvery honest userFewer people reach paying
Manual review, one minute eachWhat a person can spotAnything after hoursWhoever looks odd to a tired reviewer1,100 minutes, about 18 hours

That rate limit line stings. Supabase's default for signups is 30 requests per 5 minutes per IP address, which is 360 an hour. The scenario's 920 accounts over 144 hours is about 6 an hour.

Stack these up and your hook gets longer, inside a budget of 2 seconds, and a timeout returns an error. Every rule you add to protect signups is one more way to break them.

Every rule passesA rule firesSame person, new signupNew domainSecond real mailboxSame inbox, new spellingAnother networkYour hookEmail confirmedCredits granted againA real coworker refused
Every rule passesA rule firesSame person, new signupNew domainSecond real mailboxSame inbox, new spellingAnother networkYour hookEmail confirmedCredits granted againA real coworker refused

What to set up this week

Turn on Confirm email and add your own email sender. Accounts that never confirm now cost you one email.

Keep the hook short. Log what a new rule would refuse for a week before it refuses anyone.

Move free credits off signup. Supabase's docs show an after insert trigger on auth.users for profile rows. Put credits in that trigger and they're granted when the row is created. Grant them from one server function instead, after confirmation, when someone first asks for the credits.

Give free traffic its own budget. With a hard cap for free users, paying customers keep working. In the scenario, a $300 free cap stops at 100 accounts ($300 ÷ $3.00).

Write the refusal yourself. The hook's message reaches real people too. Tell them how to reach you.

Do all five and the $2,760 week gets a lot smaller. But account 921 still arrives with a confirmed email and nothing on paper tying it to the last 920.

Answering the question your hook can't

You've now got a domain list that goes stale, an IP rule that can land on a whole office and a hook on a 2-second clock. You don't have to build your own abuse prevention system. AbuseZero was made to evaluate whether this claim looks like a repeat, which Supabase Auth was never meant to do, and it's very good at it.

Where your rule looks at one domain, AbuseZero checks mailbox aliases, disposable domains and mail routing. Where yours sees an IP address, AbuseZero sees beyond it with VPN, hosting, network reputation, Tor and proxy intelligence. It recognizes repeat devices across new accounts, even when email addresses keep changing, so creating a fresh account isn't enough to erase previous activity. A single check looks at one thing. AbuseZero's multi-layer AI risk analysis examines 140,000+ signals, detects linked claims and flags abuse that single checks miss. Those signals are read together, never one at a time. There's also a proprietary algorithm, with AI that checks the claim again.

Supabase Auth keeps handling sign-in. When someone claims the free benefit, one API call gets you a clear allow or deny, under rules you control, and Observe mode shows you what would be denied before anyone is blocked. The quickstart gets your first benefit protected.

Frequently asked questions

Does Supabase Auth prevent duplicate accounts?

For the same email address, yes. For one person using different addresses, no. It has no way to know they're the same person.

How do I merge duplicates that already exist?

Supabase's automatic linking only covers matching email addresses, so anything else is a support decision. Start with how to merge duplicate accounts without upsetting customers.

Do I have to replace Supabase Auth to add an evaluation?

No. AbuseZero's evaluation runs when a benefit is claimed, and your application keeps its sign-in as it is.

Keep your free credits for new people

Keep reading

Copying your prompt…

Copied the to your clipboard. Give it to your coding agent & it will handle the rest.