Skip to main content

Supabase Authentication

Add user accounts to your app with Supabase Auth. Users can sign up, log in, reset passwords, and maintain sessions across app launches.

Prerequisites


Setting Up Auth

Tell Nativeline what you need:
Nativeline will create:
  • Auth service/manager
  • Login screen
  • Signup screen
  • Session handling

Authentication Flow

Signup Flow

Login Flow

Session Persistence

Supabase handles session tokens automatically:
  • Tokens stored securely
  • Auto-refresh before expiry
  • User stays logged in across app launches

Creating Auth Screens

Signup Screen

Login Screen

Password Reset


Handling Auth State

Check if User is Logged In

Get Current User

Sign Out


Email Verification (Optional)

By default, Supabase can require email verification:

Enable in Supabase Dashboard

  1. Authentication → Settings
  2. Toggle “Enable email confirmations”
  3. Customize email template if desired

Handle in App

Disable for Testing

For development, you can disable email confirmation:
  1. Supabase Dashboard → Authentication → Settings
  2. Disable “Enable email confirmations”

Protecting Data with User IDs

Associate Data with Users

When saving data, include the user’s ID:

Row Level Security

In Supabase, create policies so users only see their data:

Handling Auth Errors

Common Errors

Error Handling in App


Auth Best Practices

Validate inputs before sending to Supabase. But also rely on Supabase’s server-side validation — don’t trust client validation alone.
Require at least 6 characters (Supabase default). Consider:
  • Minimum 8 characters
  • Mix of letters and numbers
  • Password strength indicator
Let Supabase handle token refresh automatically. Don’t store passwords locally. Clear sessions on logout.
When login fails, say “Invalid email or password” — not “User not found.” This prevents account enumeration attacks.

Testing Auth

In Simulator

  1. Create a test account
  2. Verify login works
  3. Close and reopen app (should stay logged in)
  4. Test logout
  5. Test password reset flow

Reset Test Users

In Supabase Dashboard:
  1. Authentication → Users
  2. Find test user
  3. Delete or modify as needed

Advanced: Social Auth (Future)

Supabase supports social logins (Google, Apple, GitHub). These require additional setup:
  • Apple: Requires Apple Developer account
  • Google: Requires Google Cloud setup
  • OAuth: Various providers
Contact Nativeline support for guidance on social auth setup.

Next Steps

Database

Store user data in tables

Storage

Upload user profile photos