Supabase is an open-source Firebase alternative that provides authentication, database, and storage services. This guide shows you how to integrate Supabase authentication with your Dev Portal documentation site.
Prerequisites
You'll need a Supabase project. If you don't have one, create a free Supabase project to get started.
Setup Steps
-
Configure Authentication Provider
In your Supabase Dashboard:
- Navigate to Authentication → Providers
- Enable your preferred authentication provider (GitHub, Google, Azure, etc.)
- Configure the provider settings:
- Redirect URL:
https://your-project.supabase.co/auth/v1/callback - Copy any required credentials (Client ID, Client Secret) from the provider
- Redirect URL:
-
Get Your Project Credentials
From your Supabase project dashboard:
- Go to Settings → Data API
- Copy your Project URL (looks like
https://your-project.supabase.co) - Go to Settings → API Keys
- Copy your anon public API key
-
Configure Zudoku
Add the Supabase configuration to your Dev Portal configuration file:
zudoku.config.tsYou can configure multiple providers:
zudoku.config.ts -
Install Supabase Dependencies
Add
@supabase/supabase-jsto your project dependencies:Code
Supported Providers
Supabase supports numerous authentication providers. Use any of these values in the providers
array:
apple- Sign in with Appleazure- Microsoft Azure ADbitbucket- Bitbucketdiscord- Discordfacebook- Facebookfigma- Figmagithub- GitHubgitlab- GitLabgoogle- Googlekakao- Kakaokeycloak- Keycloaklinkedin/linkedin_oidc- LinkedInnotion- Notionslack/slack_oidc- Slackspotify- Spotifytwitch- Twitchtwitter- Twitter/Xworkos- WorkOSzoom- Zoomfly- Fly.io
Email/password authentication does not need to be specified as a provider because it is enabled by
default in Supabase. To disable email/password authentication and only use OAuth providers, set
onlyThirdPartyProviders: true in your configuration.
Configuration Options
All available configuration options for Supabase authentication:
zudoku.config.ts
Authentication Routes
The Supabase authentication provider automatically creates the following routes:
/signin- Sign in page with configured providers/signup- Sign up page with configured providers/signout- Sign out endpoint
If you configure a custom basePath, these routes will be prefixed with that path (e.g.,
/docs/signin).
Advanced Configuration
User Profile Data
Dev Portal automatically extracts the following user information from Supabase authentication:
sub- User ID from Supabaseemail- User's email addressname- User's full name (fromuser_metadata.full_nameoruser_metadata.name)emailVerified- Whether the email has been confirmedpictureUrl- User's avatar URL (fromuser_metadata.avatar_url)
Additional User Metadata
To store and access additional user information beyond what's provided by Supabase authentication:
- Create a
profilestable in your Supabase database - Set up a database trigger to create profile records on user signup
- Use the Supabase client to query this data in your application
Example profile table structure:
Code
Troubleshooting
Common Issues
-
"At least one provider must be provided" Error: You must configure the
providersoption in your authentication configuration with at least one authentication provider in the array. -
Invalid API Key: Ensure you're using the
anon publickey, not theservice_rolekey from your Supabase project settings. -
Provider Not Working: Verify the provider is enabled in your Supabase dashboard and properly configured with the correct redirect URLs.
-
Redirect URLs: For local development, update your redirect URLs in both Supabase and the OAuth provider to include
http://localhost:3000. -
CORS Errors: Check that your site's domain is properly configured in Supabase's allowed URLs under Authentication → URL Configuration.
-
Authentication Not Working: Make sure you have installed all required dependencies:
@supabase/supabase-js,@supabase/auth-ui-react, and@supabase/auth-ui-shared.
Next Steps
- Explore Supabase Auth documentation for advanced features
- Learn about protecting routes in your documentation