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

How to Set Up a Custom Domain in Firebase Hosting

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.

What you'll learn

  • How to add and verify a custom domain in the Firebase Console
  • How to configure DNS A records at your domain registrar
  • How Firebase provisions and renews SSL certificates automatically
  • How to set up both root domain and www subdomain
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Intermediate6 min read15-20 minFirebase Hosting (Spark and Blaze plans), any domain registrarMarch 2026RapidDev Engineering Team
TL;DR

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

1

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.

2

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.

typescript
1# Example DNS TXT record
2# Host: @
3# Type: TXT
4# Value: firebase-site-verification=abc123xyz789
5# TTL: 3600

Expected result: Firebase verifies your domain ownership and shows the next step with A record values.

3

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 @.

typescript
1# Firebase Hosting A records (as of 2026)
2# Host: @
3# Type: A
4# Value: 151.101.1.195
5# TTL: 3600
6
7# Host: @
8# Type: A
9# Value: 151.101.65.195
10# TTL: 3600

Expected result: Two A records are added to your DNS configuration pointing your domain to Firebase Hosting servers.

4

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.

typescript
1# DNS CNAME record for www subdomain
2# Host: www
3# Type: CNAME
4# Value: your-project.web.app
5# TTL: 3600

Expected result: Visitors to www.example.com are redirected to example.com with a 301 status code.

5

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.

6

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

firebase.json
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.

ChatGPT Prompt

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.

Firebase Prompt

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.

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.