0
0
Firebasecloud~7 mins

Custom domain configuration in Firebase - Commands & Configuration

Choose your learning style9 modes available
Introduction
Custom domain configuration lets you use your own website address instead of the default Firebase URL. This makes your site look professional and easier to remember.
When you want your website to have a branded address like www.myapp.com instead of myapp.firebaseapp.com
When you want to improve trust with visitors by showing your own domain name
When you want to use HTTPS with your custom domain for secure connections
When you want to manage your website and domain settings in one place
When you want to link your Firebase hosting to a domain you already own
Commands
This command creates a new hosting site in Firebase for your app. It prepares Firebase to link your custom domain.
Terminal
firebase hosting:sites:create my-app-site
Expected OutputExpected
✔ Hosting site my-app-site created successfully
This deploys your website to the live channel of the hosting site you created. It makes your site ready to connect with your custom domain.
Terminal
firebase hosting:channel:deploy live --site my-app-site
Expected OutputExpected
✔ Deploy complete! Project Console: https://console.firebase.google.com/project/my-app/hosting/sites/my-app-site
--site - Specifies which hosting site to deploy to
This command starts the process to link your custom domain to your Firebase hosting site. Firebase will give you DNS records to add to your domain provider.
Terminal
firebase hosting:domain:add www.mycustomdomain.com --site my-app-site
Expected OutputExpected
✔ Domain www.mycustomdomain.com added to site my-app-site Please add the following DNS records to your domain provider to verify ownership and enable hosting.
--site - Specifies which hosting site to link the domain to
This command shows the list of custom domains linked to your hosting site and their verification status.
Terminal
firebase hosting:domain:list --site my-app-site
Expected OutputExpected
Domain Name Status www.mycustomdomain.com Pending Verification
--site - Shows domains for the specified hosting site
Key Concept

If you remember nothing else from this pattern, remember: you must add the DNS records Firebase gives you to your domain provider to verify and activate your custom domain.

Common Mistakes
Not adding the DNS records to the domain provider after running the domain:add command
Without DNS records, Firebase cannot verify your domain ownership and the custom domain won't work.
Copy the DNS records Firebase shows and add them exactly to your domain provider's DNS settings.
Deploying to the default hosting site instead of the site linked to the custom domain
Your custom domain points to a specific hosting site, so deploying elsewhere means your domain won't show the updated site.
Always use the --site flag with deploy commands to target the correct hosting site.
Summary
Create a Firebase hosting site for your app using firebase hosting:sites:create.
Deploy your website to the hosting site with firebase hosting:channel:deploy.
Add your custom domain to the hosting site with firebase hosting:domain:add and get DNS records.
Add the DNS records to your domain provider to verify ownership and activate the domain.
Check domain status with firebase hosting:domain:list.