Skip to content

Updated

Anonymous sign-ins

Create and use anonymous users to authenticate with Supabase

Enable anonymous sign-ins to give users an authenticated experience without asking for an email address, password, OAuth provider, or other personally identifiable information (PII). Later, the user can link an authentication method and become a permanent user. On a self-hosted or local project, enable it in the CLI configuration instead.

How anonymous users differ

An anonymous user behaves like a permanent user, but loses access to their account when they sign out, clear browsing data, or use another device. Don't confuse an anonymous user with the anon API key, which doesn't create a user at all.

Anonymous userPermanent useranon API key
Creates a userYes, with signInAnonymously()YesNo
Postgres roleauthenticatedauthenticatedanon
is_anonymous claimtruefalseNone
Survives sign-out or a new deviceNoYesNot applicable

Sign in anonymously

Call the signInAnonymously() method:

const { , } = await ..()

Call the signInAnonymously() method:

await supabase.auth.signInAnonymously();

Call the signInAnonymously() method:

let session = try await supabase.auth.signInAnonymously()

Call the signInAnonymously() method:

supabase.auth.signInAnonymously()

Call the sign_in_anonymously() method:

response = supabase.auth.sign_in_anonymously()

Call the SignInAnonymously() method:

var session = await supabase.Auth.SignInAnonymously();

Convert an anonymous user to a permanent user

To convert an anonymous user, see Convert an anonymous user.

Abuse prevention and rate limits

Because anonymous users are stored in your database, bad actors can abuse the endpoint to inflate your database size. Enable invisible CAPTCHA or Cloudflare Turnstile to prevent abuse of anonymous sign-ins. Anonymous sign-ins have an IP-based rate limit of 30 requests per hour, which you can change in the dashboard. For every rate limit, see Rate limiting, resource allocation, and abuse prevention.

Clean up anonymous users

Supabase doesn't delete anonymous users automatically. To delete them, run SQL like this:

-- deletes anonymous users created more than 30 days ago
delete from auth.users
where is_anonymous is true and created_at < now() - interval '30 days';

When to use anonymous sign-ins

Use anonymous sign-ins to build:

  • E-commerce applications, such as shopping carts before checkout
  • Full-feature demos without collecting personal information
  • Temporary or throwaway accounts

To read more about anonymous users, see these pages: