Search code examples
next.jsfirebase-hosting

understanding how server-time is calculated when integrating next.js with firebase-hosting?


I want to make a general refactor to my app that will mover from react.js (client-side) to next js with SSR, where I will use the following props to pre-render data... and my app pages,

export async function getServerSideProps(context) {
  return {
    props: {}, // will be passed to the page component as props
  }
}

how to does firebase charge for the SSR ? since it is not a cloud function, technically for next.js app to be hosted on firebase there should be a server time, as I understood the idea, how is this server time goin to be calculated in the context of the hosting and out of the context of cloud functions, please elaborate if I misunderstand the concept behind ssr with next.js and firebase.


Solution

  • Firebase Hosting on its own will never execute any of your code on its servers.

    If you run a web app that performs Server-Side Rendering on Firebase, you are using Cloud Functions or Cloud Run to execute that code for which Firebase Hosting provides convenient connectors.

    So if you get the server-side timestamp in SSR, that's also where any billing for such server-side code comes from. Also see this line from the Firebase documentation on using web frameworks:

    Prerequisites
    ...

    • Optional: Billing enabled on your Firebase project (required if you plan to use SSR).

    For a good primer on hosting server-side dynamic content on Firebase Hosting, see the documentation on serving dynamic content and host microservices using Firebase Hosting.