# Authentication

## Using Supabase (reccommended)

1. Follow [these instructions](#with-supabase) to set up supabase in your project
2. Set `requireAuth` to `true` in `config.js`. This will force the user to login before accessing the app

{% hint style="info" %}
Troubleshooting

1. Make sure `config.supabase.isSetup` is true
2. Make sure `config.requireAuth` is true
3. Make sure your supabase url and anon key is valid is valid
   {% endhint %}

## Not Using Supbase

1. Open `AuthProvider.ts`
2. Re-implement the `useEffect` using `onAuthStateChange`, and set `userID` and `isAuthInitialized`&#x20;

{% code title="AuthProvider.ts" %}

```typescript
useEffect(() => {
  supabase.auth.onAuthStateChange((_event, session) => {
    if (session) {
      setUserId(session.user.id)
    } else {
      setUserId("")
    }
    setIsAuthInitialized(true)
  })
}, [])

```

{% endcode %}

3. Re-implement the functions `handleSignUp`, `handlesignIn`, `handlesignOut`, and `handlesignInGuest` in `AuthProvider.tsx`
