2
votes

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.

1
You probably want to look into connecting Firebase Hosting to Cloud Functions. firebase.google.com/docs/hosting/functionsDoug Stevenson
Actually no, because I am not trying to serve dynamic content. I would rather update the static files inside firebase hosting from my firebase functions app. But since this is not (yet) supported, I am running my own static content server in cloud functions using express..L. Heider
You can put Firebase Hosting in front Cloud Functions to help solve much of the billing and performance problems you face by trying to serve all your static content this way.Doug Stevenson
I highly recommend you check out this video from Google I/O, where one of the lead engineers on Firebase Hosting explains how to build an efficient, event-driven, content site on Firebase: youtube.com/…Frank van Puffelen

1 Answers

9
votes

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