Firebase HostingIntermediate
1Question 1 of 1
jsonHow does Firebase Hosting serve web applications and handle rewrite rules for SPAs?
Explanation & Concept
Firebase Hosting provides fast, secure hosting for static assets (HTML, CSS, JS, images) and serverless web apps backed by a global CDN with free SSL certificates.
For Single Page Applications (React, Vue, Next.js), you configure rewrites in `firebase.json` to route all page requests to `index.html` so client-side routers handle navigation.
Code Example
json
{
"hosting": {
"public": "dist",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
],
"headers": [
{
"source": "**/*.@(jpg|jpeg|png|svg|webp)",
"headers": [{ "key": "Cache-Control", "value": "max-age=31536000" }]
}
]
}
}How It Works & Key Takeaways
The `**` rewrite ensures deep links (e.g. `/profile/settings`) correctly load `index.html`, letting the frontend SPA router resolve the view.
Mock Test · 1 Questions · Optional
Ready for Cloud Storage?
Take a quick test to evaluate yourself, or move straight to the next module.
Intermediate1 questions