To connect Supabase to a custom domain, go to your project's Settings in the Supabase Dashboard, navigate to the Custom Domains section, and add your domain. You will need to create a CNAME DNS record pointing to Supabase's endpoint and verify ownership. Once verified, Supabase provisions an SSL certificate automatically. Your API endpoints change from project-ref.supabase.co to your custom domain, so update all client configurations accordingly.
Setting Up a Custom Domain for Your Supabase Project
By default, your Supabase project uses a URL like project-ref.supabase.co. A custom domain lets you use your own domain (e.g., api.yourapp.com) for all Supabase API endpoints including REST, Auth, Storage, and Realtime. This improves branding, avoids ad blockers that target supabase.co, and gives you control over the domain. This tutorial walks through the setup process, DNS configuration, and client updates needed.
Prerequisites
- A Supabase project on the Pro plan or higher
- A registered domain name with access to DNS management
- Access to the Supabase Dashboard with project owner permissions
- Your application's Supabase client configuration ready to update
Step-by-step guide
Check your Supabase plan eligibility
Check your Supabase plan eligibility
Custom domains are available on the Supabase Pro plan ($25/month) and higher. If you are on the Free plan, you need to upgrade before proceeding. Navigate to your project in the Supabase Dashboard, click on the organization settings, and check your current plan. Upgrade if needed — the plan change takes effect immediately.
Expected result: Your project is on the Pro plan or higher and eligible for custom domain configuration.
Navigate to Custom Domains in the Dashboard
Navigate to Custom Domains in the Dashboard
In the Supabase Dashboard, select your project and go to Project Settings in the left sidebar. Look for the Custom Domains section (it may be under the General or API tab depending on the Dashboard version). Click Add custom domain to begin the setup process. You will be asked to enter the subdomain you want to use — this should be a subdomain like api.yourapp.com or supabase.yourapp.com, not a root domain.
Expected result: The custom domain setup form is open and ready for your subdomain input.
Create a CNAME DNS record for your domain
Create a CNAME DNS record for your domain
Supabase will provide a CNAME target value that you need to add as a DNS record with your domain registrar or DNS provider. Log into your DNS management panel (Cloudflare, Route53, Namecheap, GoDaddy, etc.) and create a CNAME record. Set the name to your chosen subdomain (e.g., api) and the value to the target Supabase provides. DNS propagation can take up to 48 hours, but typically completes within 15-30 minutes.
1# DNS Record Configuration2# Type: CNAME3# Name: api (for api.yourapp.com)4# Value: <project-ref>.supabase.co (provided by Supabase)5# TTL: 3600 (or Auto)67# Example for Cloudflare:8# Type: CNAME9# Name: api10# Target: abcdefghijk.supabase.co11# Proxy: DNS only (gray cloud) — do NOT proxy through CloudflareExpected result: A CNAME record is created pointing your subdomain to Supabase's endpoint.
Verify domain ownership and wait for SSL provisioning
Verify domain ownership and wait for SSL provisioning
After creating the DNS record, return to the Supabase Dashboard and click Verify to check the DNS configuration. Supabase will look up your CNAME record and confirm it points to the correct target. Once verified, Supabase automatically provisions an SSL certificate for your custom domain using Let's Encrypt. The SSL certificate is auto-renewed before expiration. The verification and SSL process usually completes within a few minutes.
Expected result: Domain ownership is verified and an SSL certificate is provisioned. Your custom domain shows as active in the Dashboard.
Update your Supabase client configuration
Update your Supabase client configuration
Once the custom domain is active, update all Supabase client initializations in your application to use the new URL. Replace the default project-ref.supabase.co URL with your custom domain. The anon key and service role key remain the same — only the URL changes. Update all environments (development, staging, production) and any CI/CD configurations that reference the Supabase URL.
1import { createClient } from '@supabase/supabase-js'23// Before: default Supabase URL4// const supabase = createClient(5// 'https://abcdefghijk.supabase.co',6// 'your-anon-key'7// )89// After: custom domain10const supabase = createClient(11 'https://api.yourapp.com',12 'your-anon-key' // Same key, no change needed13)1415// Environment variable approach (recommended)16const supabase = createClient(17 process.env.NEXT_PUBLIC_SUPABASE_URL!, // Update this env var18 process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!19)Expected result: Your application connects to Supabase through the custom domain. All API, Auth, Storage, and Realtime requests go through the new URL.
Update OAuth redirect URLs and email templates
Update OAuth redirect URLs and email templates
If you use OAuth providers (Google, GitHub, etc.) or send auth emails (confirmation, password reset), update the redirect URLs to use your custom domain. In the Supabase Dashboard under Authentication > URL Configuration, update the Site URL and redirect URLs. Also update the callback URLs configured in your OAuth provider dashboards (Google Cloud Console, GitHub Developer Settings, etc.) to point to your custom domain.
1# Update in Supabase Dashboard > Authentication > URL Configuration:2# Site URL: https://yourapp.com3# Redirect URLs: https://yourapp.com/auth/callback45# Update OAuth callback in provider dashboards:6# Before: https://abcdefghijk.supabase.co/auth/v1/callback7# After: https://api.yourapp.com/auth/v1/callbackExpected result: OAuth flows and email confirmations work correctly through the custom domain.
Complete working example
1import { createClient } from '@supabase/supabase-js'23// Configuration with custom domain4const SUPABASE_URL = process.env.NEXT_PUBLIC_SUPABASE_URL!5// For custom domain: 'https://api.yourapp.com'6// For default: 'https://project-ref.supabase.co'78const SUPABASE_ANON_KEY = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!9// The anon key does NOT change when using a custom domain1011export const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY)1213// Test the connection through the custom domain14async function testConnection() {15 // Test database access16 const { data, error } = await supabase17 .from('todos')18 .select('count')19 .limit(1)2021 if (error) {22 console.error('Connection failed:', error.message)23 return false24 }2526 console.log('Connected via custom domain successfully')27 return true28}2930// Test auth through the custom domain31async function testAuth() {32 const { data: { user } } = await supabase.auth.getUser()33 if (user) {34 console.log('Auth working via custom domain:', user.email)35 } else {36 console.log('No active session')37 }38}3940// Test storage through the custom domain41function testStorageUrl() {42 const { data } = supabase.storage43 .from('avatars')44 .getPublicUrl('test.png')4546 // URL should use your custom domain47 console.log('Storage URL:', data.publicUrl)48 // Expected: https://api.yourapp.com/storage/v1/object/public/avatars/test.png49}5051export { testConnection, testAuth, testStorageUrl }Common mistakes when connecting Supabase to a Custom Domain
Why it's a problem: Using Cloudflare proxy (orange cloud) for the CNAME record, which interferes with SSL provisioning and WebSocket connections
How to avoid: Set the Cloudflare proxy status to DNS only (gray cloud). Supabase handles SSL and proxying — adding another proxy layer causes conflicts.
Why it's a problem: Trying to set a CNAME on the root domain (yourapp.com) which is not supported by standard DNS
How to avoid: Use a subdomain like api.yourapp.com. CNAME records on root domains require CNAME flattening support (available on Cloudflare and Route53, but not all providers).
Why it's a problem: Forgetting to update OAuth callback URLs after switching to the custom domain, breaking sign-in flows
How to avoid: Update callback URLs in both the Supabase Dashboard (Authentication > URL Configuration) and each OAuth provider's developer console.
Why it's a problem: Updating the Supabase URL in code but not in environment variables, causing different behavior between environments
How to avoid: Always use environment variables for the Supabase URL. Update the variable in your deployment platform (Vercel, Netlify, etc.) as well as local .env files.
Best practices
- Use a subdomain like api.yourapp.com rather than the root domain for CNAME compatibility
- Store the Supabase URL in environment variables so you can change it without code changes
- Disable Cloudflare proxy (use DNS only) for the CNAME record to avoid SSL and WebSocket issues
- Test the full auth flow after migration — OAuth callbacks are the most common failure point
- Update all environments (dev, staging, prod) and CI/CD pipelines with the new URL
- Keep the default supabase.co URL as a fallback in case of DNS issues
- Monitor SSL certificate renewal — Supabase handles it automatically but check periodically
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I want to connect a custom domain to my Supabase project so all API requests go through api.myapp.com instead of the default supabase.co URL. Walk me through the DNS setup, Dashboard configuration, and client updates needed.
Help me set up a custom domain for my Supabase project. I need to know the DNS configuration, how to verify the domain in the Dashboard, and how to update my application code and OAuth settings to use the new domain.
Frequently asked questions
Which Supabase plan supports custom domains?
Custom domains are available on the Pro plan ($25/month) and higher. The Free plan does not support custom domains for the Supabase API.
Do I need to change my API keys when using a custom domain?
No. Only the URL changes. The anon key, service role key, and JWT secret remain exactly the same.
Can I use my root domain (yourapp.com) instead of a subdomain?
Standard DNS does not support CNAME records on root domains. You need a DNS provider that supports CNAME flattening (like Cloudflare) or use a subdomain like api.yourapp.com.
How long does DNS propagation take?
DNS changes typically propagate within 15-30 minutes, but can take up to 48 hours in some cases. You can check propagation status at dnschecker.org.
Does Supabase handle SSL for the custom domain?
Yes. Supabase automatically provisions and renews SSL certificates using Let's Encrypt once the domain is verified. No manual SSL configuration is needed.
Will my existing default supabase.co URL stop working?
No. The default URL continues to work alongside the custom domain. Both URLs point to the same project. You can migrate gradually.
Can RapidDev help configure a custom domain for my Supabase project?
Yes. RapidDev can handle the full setup including DNS configuration, domain verification, client updates, and OAuth migration to ensure a smooth transition to your custom domain.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation