# Hosting, App Hosting and Preview Channels — Firebase

Source: https://www.skillbyai.com/en/firebase/ho-deploy

> Deploying web apps.

## Two hosting products

**Firebase Hosting** serves static assets and single-page apps from a global CDN with HTTPS, custom domains, redirects and rewrites (including rewrites to Cloud Functions or Cloud Run for dynamic routes). Configuration lives in `firebase.json`. **Preview channels** deploy a build to a temporary URL that expires, ideal for pull-request previews. **Firebase App Hosting** is aimed at server-rendered frameworks such as Next.js and Angular: it connects to a GitHub repository and builds and rolls out on push. Framework support and features differ between the two and change over time, so check the docs.

## Ship it and keep users engaged

Hosting serves your web app; Messaging, Remote Config, Analytics and Crashlytics help you operate it.

![Three ideas: deploys and previews, push messaging, config and insight tools.](assets/figures/firebase/section-7-map.svg) — Figure 7.1 — Hosting, messaging and operational features.

## Config and CLI commands

firebase.json and Firebase CLI (shown, not run).

```bash
# firebase.json (excerpt)
# {
#   "hosting": {
#     "public": "dist/app/browser",
#     "ignore": ["firebase.json", "**/.*"],
#     "rewrites": [{ "source": "**", "destination": "/index.html" }]
#   }
# }

firebase login
firebase init hosting
npm run build
firebase deploy --only hosting

# temporary preview URL for a branch or pull request
firebase hosting:channel:deploy pr-42 --expires 7d
```

## Preview every pull request

Wire preview channels into CI so reviewers can open a live URL for each change before it reaches production.

**Quiz:** What is a Hosting preview channel?

- [ ] A push notification topic
- [ ] A second Firestore database
- [ ] A Remote Config parameter
- [x] A temporary URL for a build that can expire automatically

*Answer:* A temporary URL for a build that can expire automatically. Previews separate review from production.
