Skip to content

Latest commit

 

History

History
 
 

remix-auth-supabase-github

Remix Auth - Supabase Strategy with oauth (GitHub)

Authentication using signIn with oauth provider.

Enable GitHub Auth for your project

Preview

Open this example on CodeSandbox:

Open in CodeSandbox

Setup

  1. Copy .env.example to create a new file .env:
cp .env.example .env
  1. Go to https://app.supabase.io/project/{PROJECT}/api?page=auth to find your secrets
  2. Add your SUPABASE_URL, SUPABASE_SERVICE_ROLE and PUBLIC_SUPABASE_ANON_KEY in .env
SUPABASE_SERVICE_KEY="{SERVICE_KEY}"
PUBLIC_SUPABASE_ANON_KEY="{ANON_KEY}"
SUPABASE_URL="https://{YOUR_INSTANCE_NAME}.supabase.co"

Using the Remix Auth & SupabaseStrategy 🚀

SupabaseStrategy provides checkSession working like Remix Auth isAuthenticated but handles token refresh

You must use checkSession instead of isAuthenticated

Example

This is using Remix Auth, remix-auth-supabase and supabase-js packages.

⚠️ Never expose your service_role key in the browser

The /login route renders a form with a email and password input. After a submit it runs some validations and store user object, access_token and refresh_token in the session.

The /private routes redirects the user to /login if it's not logged-in, or shows the user email and a logout form if it's logged-in.

Handle refreshing of tokens (if expired) or redirects to /login if it fails

More use cases can be found on Supabase Strategy - Use cases

Related Links