Skip to main content
RapidDev - Software Development Agency
supabase-tutorial

How to Connect Supabase to a Custom Domain

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.

What you'll learn

  • How to configure a custom domain for your Supabase project
  • How to set up DNS CNAME records for domain verification
  • How to update client configurations to use the new domain
  • How to handle SSL certificate provisioning and renewal
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Intermediate7 min read20-30 minSupabase Pro plan or higher, custom domain requiredMarch 2026RapidDev Engineering Team
TL;DR

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

1

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.

2

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.

3

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.

typescript
1# DNS Record Configuration
2# Type: CNAME
3# Name: api (for api.yourapp.com)
4# Value: <project-ref>.supabase.co (provided by Supabase)
5# TTL: 3600 (or Auto)
6
7# Example for Cloudflare:
8# Type: CNAME
9# Name: api
10# Target: abcdefghijk.supabase.co
11# Proxy: DNS only (gray cloud) do NOT proxy through Cloudflare

Expected result: A CNAME record is created pointing your subdomain to Supabase's endpoint.

4

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.

5

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.

typescript
1import { createClient } from '@supabase/supabase-js'
2
3// Before: default Supabase URL
4// const supabase = createClient(
5// 'https://abcdefghijk.supabase.co',
6// 'your-anon-key'
7// )
8
9// After: custom domain
10const supabase = createClient(
11 'https://api.yourapp.com',
12 'your-anon-key' // Same key, no change needed
13)
14
15// Environment variable approach (recommended)
16const supabase = createClient(
17 process.env.NEXT_PUBLIC_SUPABASE_URL!, // Update this env var
18 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.

6

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.

typescript
1# Update in Supabase Dashboard > Authentication > URL Configuration:
2# Site URL: https://yourapp.com
3# Redirect URLs: https://yourapp.com/auth/callback
4
5# Update OAuth callback in provider dashboards:
6# Before: https://abcdefghijk.supabase.co/auth/v1/callback
7# After: https://api.yourapp.com/auth/v1/callback

Expected result: OAuth flows and email confirmations work correctly through the custom domain.

Complete working example

supabase-custom-domain.ts
1import { createClient } from '@supabase/supabase-js'
2
3// Configuration with custom domain
4const SUPABASE_URL = process.env.NEXT_PUBLIC_SUPABASE_URL!
5// For custom domain: 'https://api.yourapp.com'
6// For default: 'https://project-ref.supabase.co'
7
8const SUPABASE_ANON_KEY = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
9// The anon key does NOT change when using a custom domain
10
11export const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY)
12
13// Test the connection through the custom domain
14async function testConnection() {
15 // Test database access
16 const { data, error } = await supabase
17 .from('todos')
18 .select('count')
19 .limit(1)
20
21 if (error) {
22 console.error('Connection failed:', error.message)
23 return false
24 }
25
26 console.log('Connected via custom domain successfully')
27 return true
28}
29
30// Test auth through the custom domain
31async 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}
39
40// Test storage through the custom domain
41function testStorageUrl() {
42 const { data } = supabase.storage
43 .from('avatars')
44 .getPublicUrl('test.png')
45
46 // URL should use your custom domain
47 console.log('Storage URL:', data.publicUrl)
48 // Expected: https://api.yourapp.com/storage/v1/object/public/avatars/test.png
49}
50
51export { 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.

ChatGPT Prompt

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.

Supabase Prompt

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.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.