firebase-hostingfirebase-toolsastrojs

How do I Deploy Astro SSR to Firebase Hosting


What:
I am looking to build and deploy an Astro SSR project to Firebase hosting.

Problem / Issue:

  1. Astro requires an adapter to be installed to build. I installed the node adapter; which is definitely not the right thing to do

  2. Firebase hosting docs says it supports SSR (next JavaScript) - Docs

  3. Have no idea how to deploy SSR. Already have a cloud function to retrieve data from firestore.


Solution

  • Adding on to gil.dev's correct answer, to use Astro with SSR, the @astrojs/node adapter is correct choice, but you must use it in middleware mode.

    import { defineConfig } from 'astro/config';
    import node from '@astrojs/node'
    
    // https://astro.build/config
    export default defineConfig({
      adapter: node({
        mode: "middleware"
      })
    });