How to Set Up SSL on Firebase Hosting Quickly
Firebase Hosting automatically provisions and renews SSL certificates for your custom domains when you add them using the Firebase Console or the Firebase CLI. Simply connect your domain to Firebase Hosting, and SSL is set up without extra configuration.
Syntax
To set up SSL on Firebase Hosting, you mainly use the Firebase CLI commands and the Firebase Console. The key steps are:
firebase hosting:sites:create <site-name>- Create a hosting site (optional for multi-site projects).firebase hosting:add- Add a custom domain to your Firebase Hosting site.- Verify domain ownership via DNS records as instructed.
- Firebase automatically provisions SSL certificates for your domain.
No manual SSL certificate upload is needed because Firebase manages it for you.
bash
firebase hosting:add # Follow prompts to add your custom domain # Verify domain ownership by adding DNS TXT records # Firebase provisions SSL automatically
Example
This example shows how to add a custom domain and enable SSL on Firebase Hosting using the CLI:
bash
firebase login firebase init hosting firebase deploy firebase hosting:add # Enter your custom domain when prompted # Follow instructions to add DNS TXT record for verification # Wait for Firebase to provision SSL certificate automatically
Output
ā Success! Your domain is verified.
ā SSL certificate provisioning started.
ā Your site is now available at https://your-custom-domain.com
Common Pitfalls
Common mistakes when setting up SSL on Firebase Hosting include:
- Not verifying domain ownership by adding the required DNS TXT record, which blocks SSL provisioning.
- Using incorrect DNS records for domain verification or pointing the domain to the wrong Firebase Hosting target.
- Expecting immediate SSL availability; it can take up to 24 hours for SSL certificates to be issued.
- Trying to upload SSL certificates manually, which Firebase does not support.
bash
## Wrong: Trying to upload SSL cert manually (not supported)
# No CLI command exists for manual SSL upload
## Right: Use firebase hosting:add and verify domain
firebase hosting:add
# Follow prompts and DNS verification
# Firebase manages SSL automaticallyQuick Reference
| Step | Command/Action | Notes |
|---|---|---|
| 1 | firebase login | Log in to your Firebase account |
| 2 | firebase init hosting | Initialize hosting in your project |
| 3 | firebase deploy | Deploy your site to Firebase Hosting |
| 4 | firebase hosting:add | Add your custom domain |
| 5 | Add DNS TXT record | Verify domain ownership via DNS |
| 6 | Wait for SSL | Firebase provisions SSL automatically |
| 7 | Access site | Use https://your-custom-domain.com |
Key Takeaways
Firebase Hosting automatically provisions SSL certificates for custom domains.
Add your custom domain with 'firebase hosting:add' and verify ownership via DNS.
No manual SSL certificate upload is needed or supported.
SSL provisioning can take up to 24 hours after domain verification.
Always verify domain ownership correctly to enable SSL on your site.