Skip to content

redirect to init apphosting for webframeworks on init hosting#9887

Merged
leoortizz merged 11 commits intojh-remove-wffrom
leoortizz_remove-wfinit
Mar 4, 2026
Merged

redirect to init apphosting for webframeworks on init hosting#9887
leoortizz merged 11 commits intojh-remove-wffrom
leoortizz_remove-wfinit

Conversation

@leoortizz
Copy link
Member

@leoortizz leoortizz commented Feb 6, 2026

When running firebase init hosting, run framework detection. If a webframework with a backend is found, trigger firebase init apphosting instead.

Based on the following comments from #9843:

Description

Scenarios Tested

firebase init hosting in a webframework project

Sample Commands

firebase init hosting

When running `firebase init hosting`, run framework detection. If a Node.js webframework is found, terminate the flow with an error directing users to run
`firebase init apphosting` instead.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @leoortizz, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the firebase init hosting command by introducing intelligent web framework detection. Its primary goal is to guide users who are working with Node.js web frameworks, which often require server-side rendering capabilities, towards the more suitable firebase init apphosting command. This prevents potential misconfigurations and ensures users are directed to the correct Firebase service for their project type, improving the initial setup experience.

Highlights

  • Web Framework Detection: The firebase init hosting command now includes logic to detect common Node.js web frameworks in the project directory.
  • App Hosting Recommendation: If a Node.js web framework (excluding Flutter) is detected, the firebase init hosting process will terminate and recommend the user to run firebase init apphosting instead, as traditional Firebase Hosting is primarily for static sites.
  • Concurrent Detection: Framework detection runs concurrently with other initialization steps to minimize impact on user experience.
  • Unit Tests: New unit tests have been added to verify the correct behavior of framework detection, ensuring the recommendation is given when appropriate and the flow continues normally when no such framework is found.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/init/features/hosting/index.spec.ts
    • Added import for the frameworks module to enable testing of framework detection.
    • Introduced stubs for frameworks.discover in existing tests to isolate them from the new detection logic.
    • Added a new test case to confirm that firebase init hosting correctly recommends firebase init apphosting and throws an error when a Node.js framework is detected.
    • Added a new test case to ensure the firebase init hosting flow proceeds normally when no web framework is detected.
  • src/init/features/hosting/index.ts
    • Imported discover and WebFrameworks from the frameworks module.
    • Implemented concurrent execution of framework detection using discover at the start of the askQuestions function.
    • Added conditional logic to check the result of the framework discovery.
    • If a non-Flutter web framework is identified, the command now logs informative messages to the console and throws a FirebaseError, prompting the user to use firebase init apphosting.
Activity
  • The author, leoortizz, initiated this pull request to implement a feature based on community feedback and discussions from a previous pull request (Removing webframeworks questions from init hosting #9843).
  • The changes introduce new logic for detecting web frameworks during the firebase init hosting process.
  • New unit tests have been added to validate the framework detection and recommendation behavior.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly implements the logic to guide users with web frameworks towards App Hosting during firebase init hosting. The changes are well-contained and include tests for the new behavior. I have a couple of suggestions to improve the robustness of the implementation and enhance test coverage.

@leoortizz leoortizz force-pushed the leoortizz_remove-wfinit branch from 6a980df to cc05c02 Compare February 12, 2026 16:58
@leoortizz leoortizz changed the title recommend apphosting for webframeworks on init hosting redirect to init apphosting for webframeworks on init hosting Feb 12, 2026
@leoortizz leoortizz requested a review from annajowang February 12, 2026 21:30
@leoortizz leoortizz requested review from jhuleatt and joehan February 23, 2026 14:24
@leoortizz leoortizz force-pushed the leoortizz_remove-wfinit branch from ef7a087 to 759334a Compare February 23, 2026 15:56
Copy link
Contributor

@egilmorez egilmorez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One suggestion on the prompt text, thanks!

@leoortizz leoortizz requested a review from egilmorez February 25, 2026 14:31
setup.features?.unshift("apphosting");
return;
}
break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the user chooses "n" we should exit. We don't want more users using this experiment.

I believe this is currently just continuing with the firebase init hosting flow?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep in mind that this would also prevent users whose apps trip the detection criteria from initializing Hosting (classic) as described in our Hosting onboarding docs (internally staged version): https://firebase.devsite.corp.google.com/docs/hosting/quickstart?db=egilmore#initialize

Toward the end of that section we're saying "You can proceed with App Hosting setup or continue with Hosting (classic) for static-only deploys," so the behavior and docs are in line; but is this fully desired behavior, to stop this subset of Hosting (classic) adopters as well as the CLI experiment?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right eric, thanks for catching. The goal is to block new Web Framework participants (which I believe the current code is doing and my comment was incorrect).

If we DID just exit here and block hosting onboarding ideally it would be NOOP because ideally, what is detected as a would-be web framework participant would also NOT be a plain (non-web framework) hosting user.

but that's not true if the detection is imperfect.

So, i see no harm in keeping this code as is. wrong detection or no wrong detection, we're already telling users that the app might not work with hosting. They can continue with plain hosting and see what happens.

So no change here....but then I think we WOULD need to to change the code below. For any other ssr apps (that don't work out of the box with app hosting), to be consistent we should let users proceed with hosting if they wish.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@egilmorez @annajowang Thanks for the feedback. I believe I have implemented the changes mentioned, please let me know if I missed anything

Copy link
Contributor

@egilmorez egilmorez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question about the "n" interactive behavior that I think is important. PTAL, thanks!

setup.features?.unshift("apphosting");
return;
}
break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep in mind that this would also prevent users whose apps trip the detection criteria from initializing Hosting (classic) as described in our Hosting onboarding docs (internally staged version): https://firebase.devsite.corp.google.com/docs/hosting/quickstart?db=egilmore#initialize

Toward the end of that section we're saying "You can proceed with App Hosting setup or continue with Hosting (classic) for static-only deploys," so the behavior and docs are in line; but is this fully desired behavior, to stop this subset of Hosting (classic) adopters as well as the CLI experiment?

@annajowang
Copy link
Contributor

annajowang commented Mar 2, 2026

I'm getting the following error:

.....                                                                                                                                                       
                                                                                                                                                                                                                         
=== Hosting Setup                                                                                                                                                                                                        
                                                                                                                                                                                                                         
✔ Detected a Next.js codebase with SSR features. We can't guarantee that this site will work on Firebase Hosting, which is optimized for static sites. Another product, Firebase App Hosting, was designed for SSR web   
apps. Would you like to use App Hosting instead? Learn more here: https://firebase.google.com/docs/app-hosting/product-comparison#hostings Yes                                                                           
                                                                                                                                                                                                                         
=== App Hosting Setup                                                                                                                                                                                                    
                                                                                                                                                                                                                         
Error: Unexpected error occurred while testing for IAM service account permissions                                                                                                                                       
                                                                                                                                                                                                                         
Having trouble? Try firebase [command] --help

It's happening even with firebase init apphosting.
but no issue when i switch to the main branch.

@leoortizz
Copy link
Member Author

I'm getting the following error:

.....                                                                                                                                                       
                                                                                                                                                                                                                         
=== Hosting Setup                                                                                                                                                                                                        
                                                                                                                                                                                                                         
✔ Detected a Next.js codebase with SSR features. We can't guarantee that this site will work on Firebase Hosting, which is optimized for static sites. Another product, Firebase App Hosting, was designed for SSR web   
apps. Would you like to use App Hosting instead? Learn more here: https://firebase.google.com/docs/app-hosting/product-comparison#hostings Yes                                                                           
                                                                                                                                                                                                                         
=== App Hosting Setup                                                                                                                                                                                                    
                                                                                                                                                                                                                         
Error: Unexpected error occurred while testing for IAM service account permissions                                                                                                                                       
                                                                                                                                                                                                                         
Having trouble? Try firebase [command] --help

It's happening even with firebase init apphosting. but no issue when i switch to the main branch.

yes that's happening to me too, it seems like there's a fix in main but not in the base branch jh-remove-wf. The base branch would need to be rebased

@leoortizz
Copy link
Member Author

I'm getting the following error:

.....                                                                                                                                                       
                                                                                                                                                                                                                         
=== Hosting Setup                                                                                                                                                                                                        
                                                                                                                                                                                                                         
✔ Detected a Next.js codebase with SSR features. We can't guarantee that this site will work on Firebase Hosting, which is optimized for static sites. Another product, Firebase App Hosting, was designed for SSR web   
apps. Would you like to use App Hosting instead? Learn more here: https://firebase.google.com/docs/app-hosting/product-comparison#hostings Yes                                                                           
                                                                                                                                                                                                                         
=== App Hosting Setup                                                                                                                                                                                                    
                                                                                                                                                                                                                         
Error: Unexpected error occurred while testing for IAM service account permissions                                                                                                                                       
                                                                                                                                                                                                                         
Having trouble? Try firebase [command] --help

It's happening even with firebase init apphosting. but no issue when i switch to the main branch.

yes that's happening to me too, it seems like there's a fix in main but not in the base branch jh-remove-wf. The base branch would need to be rebased

@annajowang I merged latest from main in the base branch/here. The error should be gone now

@leoortizz leoortizz merged commit fd8b8f9 into jh-remove-wf Mar 4, 2026
42 of 43 checks passed
@leoortizz leoortizz deleted the leoortizz_remove-wfinit branch March 4, 2026 18:05
joehan added a commit that referenced this pull request Mar 11, 2026
* Removing webframeworks questions from init hosting

* Pr fixes

* redirect to init apphosting for webframeworks on init hosting (#9887)

* recommend apphosting for webframeworks on init hosting

When running `firebase init hosting`, run framework detection. If a Node.js webframework is found, terminate the flow with an error directing users to run
`firebase init apphosting` instead.

* simplify message, use mayWantBackend instead

* update tests

* nextjs in test

* redirect to apphosting

* remove redundant comments

* keep imports order

* pr comments

* split framework detection into categories, per-framework tests

* PR comments

---------

Co-authored-by: Leonardo Ortiz <83593673+leoortizz@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants