Skip to main content
Firebase App Hosting provides a fully managed hosting solution for Next.js applications with automatic scaling, global CDN, and seamless integration with Firebase services.

Prerequisites

Before deploying to Firebase App Hosting, ensure you have:

Configuration

The project includes an apphosting.yaml configuration file that manages the Firebase App Hosting backend:
runConfig:
  # Increase this value if you'd like to automatically spin up
  # more instances in response to increased traffic.
  maxInstances: 1

Scaling Configuration

The maxInstances setting controls how many server instances Firebase will automatically spin up in response to traffic:
  • Development: Keep at 1 to minimize costs
  • Production: Increase based on expected traffic (e.g., 10, 25, 100)
Increasing maxInstances will affect your Firebase billing. Monitor your usage in the Firebase Console to avoid unexpected charges.

Deployment Steps

1

Install Firebase CLI

Install the Firebase CLI globally if you haven’t already:
npm install -g firebase-tools
2

Login to Firebase

Authenticate with your Firebase account:
firebase login
3

Initialize Firebase App Hosting

Initialize App Hosting in your project:
firebase init apphosting
Select your Firebase project and follow the prompts.
4

Configure Environment Variables

Set your environment variables in the Firebase Console:
  1. Navigate to your project in the Firebase Console
  2. Go to App Hosting > Settings
  3. Add your RESEND_API_KEY in the environment variables section
See the Environment Variables guide for details.
5

Deploy

Deploy your application:
firebase deploy --only apphosting
Firebase will build and deploy your application automatically.

Continuous Deployment

Firebase App Hosting supports automatic deployments from your Git repository:
  1. In the Firebase Console, navigate to App Hosting
  2. Click Connect to GitHub (or your preferred Git provider)
  3. Select your repository and branch
  4. Firebase will automatically deploy on every push to the selected branch
Ensure all environment variables are configured in the Firebase Console before enabling automatic deployments.

Monitoring and Logs

View your application logs and performance metrics:
firebase apphosting:logs
Or monitor in real-time through the Firebase Console under App Hosting > Logs.

Troubleshooting

Build Failures

If your deployment fails during the build step:
  1. Check the build logs: firebase apphosting:logs
  2. Verify all dependencies are listed in package.json
  3. Ensure environment variables are properly configured

Instance Scaling Issues

If you experience performance issues:
  1. Increase maxInstances in apphosting.yaml
  2. Monitor usage in the Firebase Console
  3. Consider upgrading your Firebase plan if needed

Resources

Build docs developers (and LLMs) love