xiaohongshu
xiaohongshu
firebase-app-hosting
Guide for configuring, deploying, and troubleshooting Firebase App Hosting with Next.js and other frameworks. Use when setting up apphosting.yaml, debugging build/deploy errors, managing environment variables, configuring Cloud Run settings, or adapting projects for App Hosting production environ...
Full skill instructions
This skill provides comprehensive guidance for working with Firebase App Hosting - a modern hosting solution for dynamic web apps with built-in GitHub integration, Cloud Run backend, and Cloud CDN caching.
Use this skill when:
apphosting.yaml for the first timedependencies and devDependenciesBefore deploying to Firebase App Hosting:
Project Requirements
Essential Files
apphosting.yaml in project rootpackage-lock.json, yarn.lock, or pnpm-lock.yaml (lock file required)package.json with correct dependency classificationsInitial Setup
# Initialize apphosting.yaml
firebase init apphosting
# Create backend
firebase apphosting:backends:create --project PROJECT_ID
Start with the basic structure. See assets/apphosting.yaml.template for a complete working example.
Minimal configuration:
runConfig:
cpu: 1
memoryMiB: 512
minInstances: 0
maxInstances: 10
env:
- variable: NODE_ENV
value: production
Key sections:
runConfig - Cloud Run service settings (CPU, memory, scaling)env - Environment variables and secretsscripts - Optional build/run command overridesoutputFiles - Optional deploy optimizationFor detailed configuration options, see references/apphosting-yaml-reference.md.
Rules for environment variables:
Build-time vs Runtime availability:
env:
# Available in both build and runtime (default)
- variable: NEXT_PUBLIC_API_URL
value: https://api.example.com
# Build-time only
- variable: NEXT_TELEMETRY_DISABLED
value: "1"
availability:
- BUILD
# Runtime only (server-side secrets)
- variable: DATABASE_URL
secret: database-url-secret
availability:
- RUNTIME
Next.js public variables:
NEXT_PUBLIC_ for browser accessSecrets management:
Common mistake to avoid:
# ❌ WRONG - Admin SDK credentials at BUILD time causes errors
- variable: FIREBASE_PRIVATE_KEY
value: "..."
availability:
- BUILD
- RUNTIME
# ✅ CORRECT - Admin SDK credentials at RUNTIME only
- variable: FIREBASE_PRIVATE_KEY
value: "..."
availability:
- RUNTIME
Critical distinction:
dependencies - Required at runtime in productiondevDependencies - Only needed during development/buildCommon issues:
Build tools in wrong section:
{
"dependencies": {
"next": "15.5.6", // ✅ Needed at runtime
"react": "^19", // ✅ Needed at runtime
"typescript": "^5" // ❌ Should be devDependency
},
"devDependencies": {
"@types/node": "^20", // ✅ Build-time only
"eslint": "^9" // ✅ Build-time only
}
}
Missing runtime dependencies:
If a package is used in production code, it must be in dependencies:
{
"dependencies": {
"firebase-admin": "^12", // ✅ Used in API routes
"stripe": "^14" // ✅ Used server-side
}
}
For detailed guidance, see references/package-json-guide.md.
# Push to live branch triggers automatic deployment
git push origin main
# Or manually create rollout
firebase apphosting:rollouts:create BACKEND_ID --project PROJECT_ID
# Monitor deployment
firebase apphosting:backends:get BACKEND_ID --project PROJECT_ID
Symptom: Works locally, fails in App Hosting with module import errors.
Causes:
devDependencies but needed at runtimeSolution:
dependenciesSymptom: process.env.VARIABLE_NAME is undefined in production.
Causes:
apphosting.yamlavailability settingNEXT_PUBLIC_ prefix for client-side variablesSolution:
apphosting.yaml env sectionNEXT_PUBLIC_ prefix for browser-accessible variablesSymptom: "Neither apiKey nor config.authenticator" error.
Cause: Admin SDK credentials available at BUILD time.
Solution: Set credentials to RUNTIME only:
env:
- variable: FIREBASE_CLIENT_EMAIL
value: "..."
availability:
- RUNTIME
- variable: FIREBASE_PRIVATE_KEY
value: "..."
availability:
- RUNTIME
Symptom: Cloud Build completes, but Cloud Run deployment fails.
Common causes:
Solution:
memoryMiB and/or cpu in runConfigFor comprehensive troubleshooting, see references/common-errors.md.
See references/nextjs-specific.md for detailed Next.js guidance including:
Key Next.js tips:
Adjust performance and cost with runConfig:
runConfig:
# Processing power
cpu: 2 # 0-8 CPUs
memoryMiB: 2048 # 128-32768 MiB
# Scaling behavior
minInstances: 0 # Minimum always-on instances
maxInstances: 100 # Maximum instances
concurrency: 80 # Requests per instance
Memory/CPU relationship:
Important: Higher memory allocations require higher CPU counts:
Connect to private resources:
runConfig:
vpcAccess:
egress: PRIVATE_RANGES_ONLY
networkInterfaces:
- network: my-network-id
subnetwork: my-subnetwork-id
Only override if framework adapters don't work:
scripts:
buildCommand: next build --no-lint
runCommand: node dist/index.js
Warning: Overriding disables framework-specific optimizations.
assets/apphosting.yaml.template - Complete working configuration examplereferences/apphosting-yaml-reference.md - All apphosting.yaml optionsreferences/common-errors.md - Troubleshooting guide with solutionsreferences/nextjs-specific.md - Next.js-specific configurationreferences/package-json-guide.md - Dependency management guidefirebase emulators:start --only apphosting
# Uses apphosting.emulator.yaml for local overrides
# Your app runs with same environment variables as production
If issues persist after following this guide:
references/common-errors.md for your specific errorxiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience