📖 Scenario: You are working on a website project using Firebase Hosting. You want to create a preview channel to test your changes before making them live. Preview channels let you share a temporary URL with your team to review updates safely.
🎯 Goal: Set up a Firebase Hosting preview channel configuration to deploy and test your website changes in a safe environment before publishing to production.
📋 What You'll Learn
Create a Firebase Hosting configuration file with the hosting target
Add a preview channel ID variable for deployment
Write the Firebase CLI command to deploy to the preview channel
Include the expiration time for the preview channel deployment
💡 Why This Matters
🌍 Real World
Preview channels let developers share and test website changes safely before making them public. This avoids breaking the live site.
💼 Career
Many cloud and web developer roles require managing staging and preview environments to ensure quality and collaboration.
Progress0 / 4 steps
1
Create Firebase Hosting configuration
Create a file named firebase.json with a hosting section that has a public directory set to public and ignore array containing firebase.json and **/.*.
Firebase
Hint
This file tells Firebase which folder to use for hosting and which files to ignore.
2
Add preview channel ID variable
Create a variable called previewChannelId and set it to the string test-channel.
Firebase
Hint
This variable will be used to name your preview channel when deploying.
3
Write Firebase CLI deploy command
Write a command string called deployCommand that uses firebase hosting:channel:deploy with the previewChannelId variable.
Firebase
Hint
This command deploys your site to the preview channel named test-channel.
4
Add expiration time for preview channel
Add an expiration time of 7 days to the deployCommand by appending --expires 7d to the command string.
Firebase
Hint
This sets the preview channel to expire automatically after 7 days.
Practice
(1/5)
1. What is the main purpose of Firebase preview channels?
easy
A. To create temporary, shareable versions of your app for testing
B. To permanently host your live app
C. To backup your Firebase database
D. To monitor app usage statistics
Solution
Step 1: Understand preview channels concept
Preview channels allow you to create temporary versions of your app that you can share for testing.
Step 2: Compare with other options
Permanent hosting, backups, and monitoring are different Firebase features unrelated to preview channels.
Final Answer:
To create temporary, shareable versions of your app for testing -> Option A
Quick Check:
Preview channels = temporary test versions [OK]
Hint: Preview channels = temporary test app versions [OK]
Common Mistakes:
Confusing preview channels with permanent hosting
Thinking preview channels backup data
Assuming preview channels track usage
2. Which command correctly creates a Firebase preview channel named test123?
easy
A. firebase hosting:channel:deploy test123
B. firebase deploy --channel test123
C. firebase hosting:deploy test123
D. firebase channel:create test123
Solution
Step 1: Recall the correct Firebase CLI command
The command to create a preview channel is firebase hosting:channel:deploy CHANNEL_ID.
Step 2: Match the command with the channel name
Replacing CHANNEL_ID with test123 gives firebase hosting:channel:deploy test123.
Final Answer:
firebase hosting:channel:deploy test123 -> Option A