Skip to content

feat: deploy adapter for Firebase#319

Merged
lazarv merged 3 commits intomainfrom
feat/adapter-firebase
Mar 1, 2026
Merged

feat: deploy adapter for Firebase#319
lazarv merged 3 commits intomainfrom
feat/adapter-firebase

Conversation

@lazarv
Copy link
Copy Markdown
Owner

@lazarv lazarv commented Mar 1, 2026

Adds a new deploy adapter for Firebase Functions v2 (Cloud Functions 2nd gen) with full streaming support, along with enhancements to the --deploy CLI flag and comprehensive EN/JA documentation.

New Firebase Functions Adapter

@lazarv/react-server/adapters/firebase

A complete deploy adapter that builds and deploys react-server applications to Firebase Cloud Functions v2 with Firebase Hosting.

How it works

  • Uses edge build mode to bundle the entire server into a single edge.mjs file
  • Generates a Cloud Function (ssr) using onRequest from firebase-functions/v2/https that handles all non-static requests
  • Configures Firebase Hosting to serve static assets from CDN and rewrite all other requests to the Cloud Function
  • Supports response streaming out of the box via Cloud Functions v2
  • Automatically generates firebase.json, .firebaserc, and the function entry point
  • Installs firebase-functions and firebase-admin dependencies in the output directory
  • Deploys via firebase deploy with proper project targeting

Adapter options

Option Type Default Description
project string from package.json name Firebase project ID
region string "us-central1" Cloud Function region
maxInstances number Max concurrent function instances
minInstances number Min warm instances (reduces cold starts)
concurrency number Max concurrent requests per instance
memory string Memory allocation (e.g. "512MiB", "1GiB")
timeoutSeconds number Function timeout

Output structure

.firebase-app/
├── firebase.json
├── .firebaserc
├── public/          # Static assets (served by Firebase Hosting CDN)
│   ├── assets/
│   ├── client/
│   └── ...
└── server/
    ├── package.json
    ├── node_modules/
    └── edge.mjs     # Bundled server function

--deploy CLI enhancement

The --deploy flag now accepts an optional JSON string to pass adapter options at deploy time, in addition to its existing boolean behavior.

# Boolean (existing behavior)
pnpm react-server build --deploy

# JSON adapter options (new)
pnpm react-server build --deploy '{"project": "my-firebase-project", "region": "europe-west1"}'

JSON options are merged with adapterOptions from the config file, with CLI values taking precedence. This is useful for CI/CD pipelines or deploying to different environments without modifying configuration files.

Core fixes

spawnCommand improvements (adapters/core.mjs)

  • Error reporting: spawnCommand now rejects with a proper Error object containing the command and exit code, instead of calling reject() with no argument (which caused TypeError: Cannot read properties of undefined (reading 'stack'))
  • Spawn options forwarding: Accepts additional spawn() options (e.g. env) beyond just cwd, enabling adapters to customize the child process environment

Documentation

New pages

  • EN: /deploy/firebase — Full adapter documentation with installation, configuration, deployment, streaming, output structure, and troubleshooting
  • JA: /deploy/firebase — Complete Japanese translation

Updated pages

  • EN/JA CLI docs (/framework/cli): --deploy section updated to document JSON options with code example
  • EN/JA Adapter API docs (/deploy/api): deploy property description updated to mention --deploy JSON support
  • EN/JA Adapters listing (/deploy/adapters): Added Firebase to adapter list and config description

AdapterGrid component i18n

  • AdapterGrid.jsx now uses useLanguage() for locale detection
  • Adapter descriptions are translated per locale (EN/JA)
  • Card links are properly prefixed with /{lang} for non-default languages
  • Firebase Functions card added to the grid

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
react-server-docs c0347d7 Mar 01 2026, 05:23 PM

@lazarv lazarv merged commit 340af0b into main Mar 1, 2026
99 of 101 checks passed
@lazarv lazarv deleted the feat/adapter-firebase branch March 1, 2026 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant