To set up a custom domain in Firebase Hosting, open your Firebase Console, go to Hosting, click Add custom domain, enter your domain name, and verify ownership by adding a TXT record to your DNS. Then point your domain to Firebase by adding the provided A records. Firebase automatically provisions a free SSL certificate once DNS propagates, which typically takes a few minutes to 24 hours.
Connecting a Custom Domain to Firebase Hosting
Firebase Hosting provides a default URL like your-project.web.app, but most production apps need a custom domain. This tutorial walks through the complete process of connecting your own domain to Firebase Hosting, including DNS verification, A record configuration, SSL certificate provisioning, and setting up both root and www subdomains with proper redirects.
Prerequisites
- A Firebase project with Hosting configured and at least one deployment
- A registered domain name with access to its DNS settings
- Firebase CLI installed and authenticated
- Your site deployed to Firebase Hosting (firebase deploy --only hosting)
Step-by-step guide
Add a custom domain in the Firebase Console
Add a custom domain in the Firebase Console
Open the Firebase Console and navigate to your project. Click Hosting in the left sidebar under Build. On the Hosting dashboard, click Add custom domain. Enter your domain name (e.g., example.com) and click Continue. If you want both the root domain and www subdomain, you will add them separately. Start with the root domain first.
Expected result: The Firebase Console shows a domain verification screen with a TXT record value to add to your DNS.
Verify domain ownership with a DNS TXT record
Verify domain ownership with a DNS TXT record
Firebase requires you to prove you own the domain by adding a TXT record to your DNS configuration. Go to your domain registrar's DNS management page (GoDaddy, Namecheap, Cloudflare, Google Domains, etc.). Add a new TXT record with the host set to @ (or leave it blank for root) and the value set to the verification string Firebase provided. Save the record and return to the Firebase Console. Click Verify. DNS changes can take minutes to hours to propagate.
1# Example DNS TXT record2# Host: @3# Type: TXT4# Value: firebase-site-verification=abc123xyz7895# TTL: 3600Expected result: Firebase verifies your domain ownership and shows the next step with A record values.
Point your domain to Firebase with A records
Point your domain to Firebase with A records
After verification, Firebase provides two IP addresses for A records. Go back to your domain registrar's DNS management and add two A records, both with the host set to @ (for root domain). Remove any existing A records for the root domain first to avoid conflicts. If you are setting up a subdomain like app.example.com, use the subdomain name as the host instead of @.
1# Firebase Hosting A records (as of 2026)2# Host: @3# Type: A4# Value: 151.101.1.1955# TTL: 360067# Host: @8# Type: A9# Value: 151.101.65.19510# TTL: 3600Expected result: Two A records are added to your DNS configuration pointing your domain to Firebase Hosting servers.
Set up the www subdomain with a redirect
Set up the www subdomain with a redirect
Most sites need both example.com and www.example.com to work. In the Firebase Console, click Add custom domain again and enter www.example.com. Firebase will ask if you want to redirect www to the root domain. Select the redirect option so that visitors to www.example.com are automatically sent to example.com. Firebase handles the redirect at the CDN level with a 301 permanent redirect. For the www subdomain, add a CNAME record at your registrar pointing www to your Firebase Hosting default URL.
1# DNS CNAME record for www subdomain2# Host: www3# Type: CNAME4# Value: your-project.web.app5# TTL: 3600Expected result: Visitors to www.example.com are redirected to example.com with a 301 status code.
Wait for SSL certificate provisioning
Wait for SSL certificate provisioning
Firebase automatically provisions a free SSL certificate from Let's Encrypt for your custom domain. This process starts once DNS propagation is complete and Firebase can verify the A records point to its servers. The certificate covers both HTTP and HTTPS, and Firebase automatically redirects all HTTP requests to HTTPS. The status appears in the Firebase Console Hosting dashboard next to your domain name. It can take anywhere from a few minutes to 24 hours.
Expected result: The Firebase Console shows a green Connected status next to your custom domain with SSL active.
Verify the custom domain is working
Verify the custom domain is working
Open your browser and navigate to your custom domain (https://example.com). Verify the site loads correctly with HTTPS. Check that the SSL certificate is valid by clicking the lock icon in the browser address bar. Test both the root domain and www subdomain to confirm the redirect works. Also test that all internal links and assets load correctly under the new domain.
Expected result: Your site loads at your custom domain over HTTPS with a valid SSL certificate and www redirects to the root domain.
Complete working example
1{2 "hosting": {3 "public": "dist",4 "ignore": ["firebase.json", "**/.*", "**/node_modules/**"],5 "rewrites": [6 {7 "source": "**",8 "destination": "/index.html"9 }10 ],11 "headers": [12 {13 "source": "**/*.html",14 "headers": [15 {16 "key": "Cache-Control",17 "value": "no-cache"18 }19 ]20 },21 {22 "source": "**/*.@(js|css|jpg|jpeg|png|gif|svg|webp|woff2)",23 "headers": [24 {25 "key": "Cache-Control",26 "value": "public, max-age=31536000, immutable"27 }28 ]29 },30 {31 "source": "**",32 "headers": [33 {34 "key": "X-Content-Type-Options",35 "value": "nosniff"36 },37 {38 "key": "X-Frame-Options",39 "value": "SAMEORIGIN"40 },41 {42 "key": "Strict-Transport-Security",43 "value": "max-age=63072000; includeSubDomains; preload"44 }45 ]46 }47 ]48 }49}Common mistakes when setting up a Custom Domain in Firebase Hosting
Why it's a problem: Leaving old A records or AAAA records in DNS alongside the Firebase A records, causing intermittent SSL provisioning failures
How to avoid: Remove all existing A and AAAA records for the domain before adding the Firebase A records. Only Firebase's IP addresses should be present.
Why it's a problem: Using Cloudflare's proxy (orange cloud) with Firebase Hosting, which intercepts SSL and causes certificate conflicts
How to avoid: Set Cloudflare DNS records to DNS only (grey cloud) for domains pointed at Firebase Hosting. Firebase handles SSL and CDN on its own.
Why it's a problem: Forgetting to add the custom domain to Firebase Auth's authorized domains list, breaking OAuth sign-in flows
How to avoid: Go to Firebase Console > Authentication > Settings > Authorized domains and add your custom domain. Without this, OAuth redirect flows will fail.
Best practices
- Always set up both root domain and www subdomain with a redirect between them for consistent user experience
- Remove all conflicting DNS records before adding Firebase A records to speed up SSL provisioning
- Use CNAME records for subdomains and A records for root domains as Firebase recommends
- Add a Strict-Transport-Security (HSTS) header in firebase.json to enforce HTTPS at the browser level
- Update OAuth redirect URLs in all authentication providers after connecting a custom domain
- Monitor the SSL certificate status in the Firebase Console after initial setup to confirm renewal works
- Test your domain with multiple browsers and devices to catch DNS caching issues
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I want to connect my custom domain to Firebase Hosting. Walk me through the complete process including DNS verification, A record setup, www subdomain redirect, and SSL certificate provisioning.
Set up a custom domain for a Firebase Hosting project including the root domain and www redirect. Show the DNS records needed, explain the SSL provisioning process, and provide a firebase.json with HSTS and security headers for the custom domain.
Frequently asked questions
Is a custom domain free on Firebase Hosting?
Yes. Custom domains and SSL certificates are free on both the Spark and Blaze plans. You only pay for your domain registration at your registrar.
How long does SSL provisioning take for a custom domain?
SSL provisioning typically completes within minutes to a few hours after DNS propagation is complete. In rare cases it can take up to 24 hours. If it takes longer, check for conflicting DNS records.
Can I use Cloudflare with Firebase Hosting?
You can use Cloudflare for DNS management, but set the Firebase records to DNS only mode (grey cloud icon). Cloudflare's proxy mode conflicts with Firebase's SSL provisioning and CDN.
How many custom domains can I connect to one Firebase Hosting site?
There is no documented limit. You can connect multiple custom domains and subdomains to the same Firebase Hosting site, each serving the same deployed content.
Does Firebase renew SSL certificates automatically?
Yes. Firebase uses Let's Encrypt certificates that auto-renew before expiration. You do not need to manage certificate renewal manually.
Can I use a subdomain like app.example.com instead of the root domain?
Yes. Add the subdomain in the Firebase Console and use a CNAME record pointing to your-project.web.app instead of A records. SSL is provisioned for the subdomain automatically.
Can RapidDev help configure custom domains and hosting for my Firebase project?
Yes. RapidDev can handle the complete hosting setup including custom domains, DNS configuration, SSL provisioning, CDN optimization, and security headers.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation