Connect a custom domain to Firebase Hosting and use it for sign-in

Updated Oct 27, 2026 · Pewterkit Guides

On your Firebase Hosting page, click Add custom domain, add the TXT and A records the wizard shows, and wait until the domain shows Connected (the SSL certificate can take up to 24 hours). Then add the domain to Authentication's authorized domains, add https://<your-domain>/__/auth/handler as a redirect URI, and set authDomain to that domain. You don't need a proxy: Hosting serves /__/auth/ on connected domains itself.

Before you start

  • Use the same Firebase project for Hosting and Auth. Firebase's docs say to set up the custom domain on the same project you use for authentication.
  • You need a Hosting site. Finish the "Get Started" wizard on your project's Hosting page first.
  • Limits: each custom domain can connect to only one Hosting site, and Firebase limits each apex domain to 20 subdomains because of SSL certificate limits.

Part 1: Connect the domain to Firebase Hosting

Step 1: Start the wizard (console UI as of Oct 2026)

On your project's Hosting page:

  • With one Hosting site, click Add custom domain.
  • With more than one site, click View on the site, then Add custom domain.

Enter the domain (for example app.example.com or example.com). The optional checkbox redirects all requests on this domain to a second domain, for example sending example.com to www.example.com. Click Continue.

Step 2: Prove you own the domain (TXT record)

If the wizard asks you to verify your apex domain, add this record at your DNS provider:

Field What to enter
Type TXT
Host / Name Your apex domain key: often @, the bare domain (example.com) or a blank field, depending on your provider
Value The verification value shown in the Firebase console

Then:

  1. Allow up to 24 hours for the record to propagate, then click Verify. Firebase says this usually happens within a few hours.
  2. If Verify shows an error, the record hasn't propagated yet or the value is wrong. You can check what's live with the Google Admin Toolbox Dig tool.
  3. Leave this TXT record in place for good. Hosting uses it to confirm ownership and to renew your SSL certificate.

You can click Cancel and come back later. Waiting doesn't reset propagation, but you'll need to re-enter the domain name.

Step 3: Point the domain at Hosting

The wizard offers two modes:

  • Quick Setup, for a new domain that isn't serving traffic yet. Add the records the wizard shows: the host is your domain key and the values are the IP addresses it gives you.
  • Advanced Setup, for moving a live site with no downtime. First add a TXT record in the form hosting-site=<site_id> (plus a pair of CAA records if the wizard asks), and complete an ACME challenge, either a DNS TXT record or a file uploaded to your current site. Once the certificate is ready, add the A/AAAA records the wizard shows. Your old host keeps serving traffic until the status changes to Connected.

Delete conflicting records. For Quick Setup, Firebase's docs say to remove any A or CNAME records that point to other providers, and any AAAA records. If any of these exist, Firebase can't issue an SSL certificate. (Advanced Setup may ask you to add AAAA records itself; keep the ones the wizard gives you.)

Host key reference:

Domain type Common Host entries
Apex (example.com) @, example.com, or blank
Subdomain (app.example.com) app.example.com, or just app

Step 4: Wait for SSL and read the status

Firebase says the certificate can take up to 24 hours after you point DNS at Hosting. While it's being issued, you may see an invalid certificate without your domain name. That's expected and clears once the certificate is ready.

Status What it means What to do
Needs setup Usually your A records haven't propagated, or (Advanced Setup) the SSL challenge failed After 24 hours, check the records point at Hosting. For a failed challenge, click View and add the new token.
Pending DNS is correct but the certificate isn't issued yet Make sure any CAA records allow letsencrypt.org and pki.goog, and stay under 20 subdomains per apex domain
Minting Certificate The certificate is being issued Wait
Connected DNS and SSL are both in place Go to Part 2

Part 2: Use the connected domain as your authDomain

Why bother? By default Firebase uses https://<project-id>.firebaseapp.com for OAuth, and its docs say users may see Continue to: https://my-app-12345.firebaseapp.com while signing in to Google. Setting your connected domain as authDomain replaces that. It's also Firebase's recommended fix (Option 1) for signInWithRedirect when you host on Firebase Hosting with a custom domain or a web.app subdomain.

Why no proxy? Firebase Hosting reserves URLs starting with /__, and Firebase Authentication uses that path for its OAuth helper pages. Reserved /__/* paths come first in Hosting's response order, ahead of redirects, static files and rewrites. So a catch-all rewrite to index.html won't hide /__/auth/handler. Firebase's Google sign-in guide states the redirect page "will be accessible on your custom domain" at /__/auth/handler.

Step 5: Add the domain to authorized domains

As of Oct 2026, Firebase's docs give Security > Authentication > Settings > Authorized domains > Add domain. Older guides use Build > Authentication > Settings. Add the exact domain your users load, for example app.example.com.

Step 6: Add the redirect URI for Google

As of Oct 2026, open the Google Auth Platform > Clients page in the Google Cloud console (older guides say Credentials), choose the web client created for your Firebase project, and add:

https://app.example.com/__/auth/handler

Google says changes to these settings can take 5 minutes to a few hours to apply. For other OAuth providers, add the same URI in their console. For SAML, add the new domain to the Assertion Consumer Service (ACS) URL.

Step 7: Change authDomain and redeploy

import { initializeApp } from "firebase/app";
import { getAuth } from "firebase/auth";

const firebaseConfig = {
  apiKey: "...",
  authDomain: "app.example.com", // was "your-project-id.firebaseapp.com"
  projectId: "your-project-id",
  appId: "...",
};

export const auth = getAuth(initializeApp(firebaseConfig));

Change only authDomain. Firebase's docs say you normally shouldn't change any other field. Then run firebase deploy --only hosting.

If you used the redirect checkbox in Step 1, set authDomain to the domain that actually serves your app, not the one that redirects. Firebase's placeholder for this value is literally <the-domain-that-serves-your-app>.

If your app is a PWA, Firebase says you must disable any service worker navigation fallback for the /__ path. For the sw-precache library, Firebase's example is:

{
  navigateFallbackWhitelist: [/^(?!\/__).*/]
}

How to confirm it worked

  1. The domain shows Connected on the Hosting page.
  2. https://app.example.com/__/firebase/init.json returns your project's Firebase config as JSON. This is a reserved Hosting URL, so it shows that Hosting, not your app, is answering /__/ paths on this domain.
  3. Click your Google sign-in button. The account chooser should no longer say firebaseapp.com. If it shows example.com rather than app.example.com, see why Google shows yourapp.com and not app.yourapp.com.
  4. Sign-in completes with no auth/unauthorized-domain and no redirect_uri_mismatch. If Google shows the mismatch error, recheck Step 6 or see redirect_uri_mismatch.

FAQ

How long does Firebase domain verification take?

Firebase says to allow up to 24 hours for the TXT record to propagate before clicking Verify, though it often takes a few hours. SSL can take up to 24 hours more after your DNS points at Hosting.

Can I delete the TXT record once the domain is connected?

No. Firebase says to keep the TXT record in your DNS permanently. Hosting uses it to confirm ownership and to issue and renew your SSL certificate.

Do I need to proxy `/__/auth/` when I use Firebase Hosting?

No. Hosting reserves the /__ path and serves Firebase Authentication's helper pages there, so https://<your-domain>/__/auth/handler works once the domain is connected. You still need Steps 5 to 7.

Can I use my `web.app` domain as `authDomain`?

Yes. Firebase's redirect guide says apps on Firebase Hosting with a custom domain or a web.app subdomain should use their own domain as authDomain. Add https://<site>.web.app/__/auth/handler as a redirect URI.

Why is my custom domain stuck on "Needs setup" or "Pending"?

"Needs setup" usually means your A records haven't propagated or still point somewhere else. Leftover AAAA, A or CNAME records also block SSL. "Pending" means DNS is correct but the certificate isn't issued yet, often because CAA records don't allow letsencrypt.org and pki.goog.

Sources

  1. Connect a custom domain (Firebase Hosting)
  2. Load Firebase SDKs from reserved URLs (Firebase Hosting)
  3. Configure Hosting behavior: priority order of Hosting responses (Firebase Hosting)
  4. Best practices for using signInWithRedirect on browsers that block third-party storage access (Firebase)
  5. Authenticate Using Google with JavaScript: customizing the redirect domain (Firebase)
  6. Authenticate with Firebase Using Email Link in JavaScript (Firebase), authorized domains steps
  7. Manage OAuth Clients (Google Cloud Platform Console Help)

How this page was made: drafted with AI from the sources listed, reviewed by Pewterkit. Docs checked Oct 27, 2026. Spotted something out of date? Tell us.

Related guides