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 user | Permanent user | anon API key | |
|---|---|---|---|
| Creates a user | Yes, with signInAnonymously() | Yes | No |
| Postgres role | authenticated | authenticated | anon |
is_anonymous claim | true | false | None |
| Survives sign-out or a new device | No | Yes | Not applicable |
Review your existing RLS policies before enabling anonymous sign-ins. Anonymous users use the authenticated role, so any policy written for signed-in users also applies to them. To tell anonymous users apart from permanent users, see Restrict anonymous user access.
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();Use dynamic rendering with Next.js
Next.js static page rendering can cache user metadata and serve it to other anonymous users. Use dynamic page rendering instead.
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 agodelete from auth.userswhere 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
Related resources
To read more about anonymous users, see these pages:
- Convert an anonymous user: link an email, phone, or OAuth identity to a guest.
- Restrict anonymous user access: tell anonymous users apart in RLS policies.
- Supabase JS Client: source and issues for the JavaScript SDK.
- Supabase Flutter Client: source and issues for the Flutter SDK.
- Supabase Kotlin Client: source and issues for the Kotlin SDK.