Suresh Kumar's photo

Can we host server side rendered react apps or next.js based apps on firebase hosting?

Frank van Puffelen's photo

Firebase Hosting on its own can only serve static resources, and won't interpret any code in the files that it serves.

But you can integrate Firebase Hosting with Cloud Functions or Cloud Run, and in that way you can use server-side rendering frameworks such as Next.js. Cloud Functions/Run in this scenario take care of executing your server-side JavaScript code, while Firebase Hosting then puts the results on its CDN with the right cache headers.

David East did a video series on this a while ago, and while it may be a bit outdated I'd still recommend checking it out.