If you are building server-rendered Angular or Next.js apps, check out next-generation Firebase App Hosting, a full-stack solution for modern web frameworks.
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-08-31 (世界標準時間)。"],[],[],null,["\u003cbr /\u003e\n\nWith the Firebase framework-aware CLI, you can deploy your Angular application\nto Firebase and serve dynamic content to your users.\n| **Note:** Framework-aware Hosting is an early public preview. This means that the functionality might change in backward-incompatible ways. A preview release is not subject to any SLA or deprecation policy and may receive limited or no support.\n| **Caution:** For developers creating a full-stack Angular app, we strongly recommend [Firebase App Hosting](/docs/app-hosting). If you're already using the frameworks experiment in the Firebase CLI, we recommend \"graduating\" to App Hosting. With App Hosting, you'll have a unified solution to manage everything from CDN to server-side rendering, along with improved GitHub integration.\n\nBefore you begin\n\nBefore you get started deploying your app to Firebase,\nreview the following requirements and options:\n\n- Firebase CLI version 12.1.0 or later. Make sure to [install the CLI](/docs/cli#install_the_firebase_cli) using your preferred method.\n- Optional: Billing enabled on your Firebase project\n (required if you plan to use SSR)\n\n- Optional: AngularFire\n\nInitialize Firebase\n\nTo get started, initialize Firebase for your framework project.\nUse the Firebase CLI for a new project, or modify `firebase.json` for an\nexisting project.\n\nInitialize a new project\n\n1. In the Firebase CLI, enable the web frameworks preview: \n\n ```\n firebase experiments:enable webframeworks\n ```\n2. Run the initialization command from the CLI and then follow the prompts:\n\n ```\n firebase init hosting\n ```\n\n \u003cbr /\u003e\n\n3. Answer yes to \"Do you want to use a web framework? (experimental)\"\n\n4. Choose your hosting source directory; this could be an existing Angular app.\n\n5. If prompted, choose Angular.\n\nInitialize an existing project\n\nChange your hosting config in `firebase.json` to have a `source` option, rather\nthan a `public` option. For example: \n\n {\n \"hosting\": {\n \"source\": \"./path-to-your-angular-workspace\"\n }\n }\n\nServe static content\n\nAfter initializing Firebase, you can serve static content with the standard\ndeployment command: \n\n firebase deploy\n\nPre-render dynamic content\n\nTo prerender dynamic content in Angular, you need to set up Angular SSR. \n\n ng add @angular/ssr\n\nSee the [Angular Prerendering (SSG) guide](https://angular.dev/guide/ssr)\nfor more information.\n\nOptional: add a server module\n\nDeploy\n\nWhen you deploy with `firebase deploy`, Firebase builds your browser bundle,\nyour server bundle, and prerenders the application. These elements are deployed\nto Hosting and Cloud Functions for Firebase.\n\nCustom deploy\n\nThe Firebase CLI assumes that you have a single application defined in your\n`angular.json` with a production build configuration.\n\nIf need to tailor the CLI's assumptions, you can either use the\n`FIREBASE_FRAMEWORKS_BUILD_TARGET` environment variable or add\n[AngularFire](https://github.com/angular/angularfire#readme) and modify your\n`angular.json`: \n\n {\n \"deploy\": {\n \"builder\": \"@angular/fire:deploy\",\n \"options\": {\n \"version\": 2,\n \"buildTarget\": \"OVERRIDE_YOUR_BUILD_TARGET\"\n }\n }\n }\n\nOptional: integrate with the Firebase JS SDK\n\nWhen including Firebase JS SDK methods in both server and client bundles, guard\nagainst runtime errors by checking `isSupported()` before using the product.\nNot all products are [supported in all environments](/docs/web/environments-js-sdk#other_environments).\n| **Tip:** consider using [AngularFire](https://github.com/angular/angularfire#readme), which does this for you automatically.\n\nOptional: integrate with the Firebase Admin SDK\n\nAdmin bundles will fail if they are included in your browser build, so consider\nproviding them in your server module and injecting as an optional dependency: \n\n // your-component.ts\n import type { app } from 'firebase-admin';\n import { FIREBASE_ADMIN } from '../app.module';\n\n @Component({...})\n export class YourComponent {\n\n constructor(@Optional() @Inject(FIREBASE_ADMIN) admin: app.App) {\n ...\n }\n }\n\n // app.server.module.ts\n import * as admin from 'firebase-admin';\n import { FIREBASE_ADMIN } from './app.module';\n\n @NgModule({\n ...\n providers: [\n ...\n { provide: FIREBASE_ADMIN, useFactory: () =\u003e admin.apps[0] || admin.initializeApp() }\n ],\n })\n export class AppServerModule {}\n\n // app.module.ts\n import type { app } from 'firebase-admin';\n\n export const FIREBASE_ADMIN = new InjectionToken\u003capp.App\u003e('firebase-admin');\n\nServe fully dynamic content with SSR\n\nOptional: integrate with Firebase Authentication\n\nThe web framework-aware Firebase deployment tooling automatically keeps client\nand server state in sync using cookies. The Express `res.locals` object will\noptionally contain an authenticated Firebase App instance (`firebaseApp`) and\nthe currently signed in user (`currentUser`). This can be injected into your\nmodule via the REQUEST token (exported from @nguniversal/express-engine/tokens)."]]