1

Disclaimer: I am new to SSR 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 js) - Docs
  3. Have no idea how to deploy SSR. Already have a cloud function to retrieve data from firestore.

Any guidance is appreciated

2 Answers 2

4

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"
  })
});

3
  • Appreciate the details @Austin I was able to deploy without any issues!
    – r2Dragon
    Jul 20 at 16:27
  • 1
    Which commands are used for deployment? the output: 'server', does not create hosting files, if the output: 'hybrid', then it creates 2 folders "client" and "server"... Do separate commands need to be executed for deployment? If so, could you kindly list those orders? If possible, could you please post the configuration for hosting and ssr with commands in steps? Thanks! Aug 20 at 10:33
  • Did you find the deployment command or the right way? I am facing the same problem :( Sep 17 at 7:00
4

I've been looking for a similar answer for the past few days. This isn't documented anywhere specifically for Astro but I followed the Next.js instructions and the app is working. The key parts are:

firebase experiments:enable webframeworks

firebase init hosting and answer yes to "Do you want to use a web framework? (experimental)"

Then when you run firebase deploy you will see that the build process looks completely different. Hope this helps.

3
  • Thanks @gil.dev - This worked perfectly! SSR + Cache FTW!
    – r2Dragon
    Jul 20 at 16:27
  • I'm getting this: Could not determine the web framework in use. Error: Unable to detect the web framework in use, check firebase-debug.log for more info. please help: I'm trying to convert SSG to SSR in the existing hosting. in the 'firebase init hosting' step CLI is asking to select a framework but Astro is not in the list and I've selected Vite and I'm getting the above error. Jul 31 at 15:23
  • Which commands are used for deployment? the output: 'server', does not create hosting files, if the output: 'hybrid', then it creates 2 folders "client" and "server"... Do separate commands need to be executed for deployment? If so, could you kindly list those orders? If possible, could you please post the configuration for hosting and ssr with commands in steps? Thanks! Aug 20 at 10:32

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.