--- id: 'auth-anonymous' title: 'Anonymous sign-ins' subtitle: 'Create and use anonymous users to authenticate with Supabase' description: 'Learn how anonymous users differ from permanent users, how to sign one in, and what limits apply, so you can decide when to let guests use your project.' --- [Enable anonymous sign-ins](/dashboard/project/_/auth/providers) 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](/docs/guides/local-development/cli/config) 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](/docs/guides/auth/auth-anonymous/access-control). ## Sign in anonymously Call the [`signInAnonymously()`](/docs/reference/javascript/auth-signinanonymously) method: ```js import { createClient } from '@supabase/supabase-js' const supabase = createClient('https://your-project-id.supabase.co', 'sb_publishable_...') // ---cut--- const { data, error } = await supabase.auth.signInAnonymously() ``` <$Show if="sdk:dart"> Call the [`signInAnonymously()`](/docs/reference/dart/auth-signinanonymously) method: ```dart await supabase.auth.signInAnonymously(); ``` <$Show if="sdk:swift"> Call the [`signInAnonymously()`](/docs/reference/swift/auth-signinanonymously) method: ```swift let session = try await supabase.auth.signInAnonymously() ``` <$Show if="sdk:kotlin"> Call the [`signInAnonymously()`](/docs/reference/kotlin/auth-signinanonymously) method: ```kotlin supabase.auth.signInAnonymously() ``` <$Show if="sdk:python"> Call the [`sign_in_anonymously()`](/docs/reference/python/auth-signinanonymously) method: ```python response = supabase.auth.sign_in_anonymously() ``` <$Show if="sdk:csharp"> Call the [`SignInAnonymously()`](/docs/reference/csharp/auth-signinanonymously) method: ```c# var session = await supabase.Auth.SignInAnonymously(); ``` 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 [#convert-an-anonymous-user-to-a-permanent-user] To convert an anonymous user, see [Convert an anonymous user](/docs/guides/auth/auth-anonymous/convert). ## Abuse prevention and rate limits Because anonymous users are stored in your database, bad actors can abuse the endpoint to inflate your [database size](/docs/guides/platform/database-size). [Enable invisible CAPTCHA or Cloudflare Turnstile](/docs/guides/auth/auth-captcha) 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](/dashboard/project/_/auth/rate-limits). For every rate limit, see [Rate limiting, resource allocation, and abuse prevention](/docs/guides/deployment/going-into-prod#rate-limiting-resource-allocation--abuse-prevention). ## Clean up anonymous users Supabase doesn't delete anonymous users automatically. To delete them, run SQL like this: ```sql -- 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 ## Related resources To read more about anonymous users, see these pages: - [Convert an anonymous user](/docs/guides/auth/auth-anonymous/convert): link an email, phone, or OAuth identity to a guest. - [Restrict anonymous user access](/docs/guides/auth/auth-anonymous/access-control): tell anonymous users apart in RLS policies. - [Supabase JS Client](https://github.com/supabase/supabase-js): source and issues for the JavaScript SDK. - [Supabase Flutter Client](https://github.com/supabase/supabase-flutter): source and issues for the Flutter SDK. - [Supabase Kotlin Client](https://github.com/supabase-community/supabase-kt): source and issues for the Kotlin SDK.