Configure Firebase Hosting with Cloud Functions
Advancedv1.0.0
Set up Firebase Hosting for static sites and SSR — deploy targets, multi-site hosting, Cloud Functions integration, and CDN caching configuration.
Content
Overview
Firebase Hosting provides fast, secure CDN hosting with HTTPS. Integrate with Cloud Functions for server-side rendering, API endpoints, and dynamic content. Configure multi-site hosting for staging and production.
Why This Matters
- -Global CDN — content served from nearest edge location
- -Free SSL — automatic HTTPS for custom domains
- -SSR support — Cloud Functions handle dynamic routes
- -Atomic deploys — all files deploy at once, no partial states
How It Works
Step 1: Basic Hosting Configuration
Step 2: Integrate Cloud Functions for SSR
Step 3: Multi-Site Hosting
Step 4: Preview Channels
Best Practices
- -Set long cache headers for hashed assets (JS, CSS with content hash)
- -Use rewrites for SPA routing and Cloud Functions integration
- -Configure multi-site hosting for staging and production
- -Use preview channels for PR review and QA testing
- -Enable security headers on all responses
- -Deploy with
firebase deploy --only hostingto avoid redeploying functions
Common Mistakes
- -Missing SPA rewrite rule (404 on client-side routes)
- -Not caching static assets (slow repeat visits)
- -Deploying everything instead of just hosting (slow deploys)
- -Not using preview channels for testing (deploying directly to production)
- -Missing security headers
FAQ
Discussion
Loading comments...