Search code examples
firebasegoogle-cloud-functionsfirebase-hosting

Downsides of firebase functions vs firebase hosting


I want to host my static webapp created with Next.js' export function on firebase. The app rebuilds itself to static html when changes in the underlying database are made. Since I can't directly deploy this static pages automatically to firebase hosting, I tend to serve the static files from with.

So, are there any downsides of serving static html content with Express.js inside firebase function compared to using firebase hosting? Especially with regard to: Pricing, Security and Performance/Speed.


Solution

  • We hosted our site (https://mfy.im) under Firebase hosting, it's generated using nuxt, similar to your next.js. We've compared many other static hosting sites including Netlify, S3, etc. Firebase hosting was the best in performance

    Even though Express can serve your static files, it's not recommended. Firebase internally uses Nginx. Nginx is super fast in serving static files and it's multithreaded. In Nginx, its easy to confiture http2, gzip etc. (full http2 support is recently released in Node 10, gzipping files in node js is also not that performant since the node is single threaded)

    Other advantages of Firebase hosting is its edge servers, built-in CDN, SSL etc. A copy of your site is deployed on multiple servers all around the world which results in low latency. I've tested Firebase CDN vs CloudFlare, again Firebase was the best

    Regarding Pricing, Firebase hosting comes with a free plan of 10GB bandwidth. It should be efficient for small-medium websites. If your bandwidth usage is higher than that you can go for 'Pay as you go'. However, if you're worried about pricing you can combine Firebase hosting with CloudFlare CDN so that CloudFlare will cover most of the bandwidth