Skip to content

feat(app): Add ability for initializeApp to accept a JSON string#9978

Draft
hsubox76 wants to merge 9 commits into
mainfrom
ch-initialize-app-env
Draft

feat(app): Add ability for initializeApp to accept a JSON string#9978
hsubox76 wants to merge 9 commits into
mainfrom
ch-initialize-app-env

Conversation

@hsubox76
Copy link
Copy Markdown
Contributor

@hsubox76 hsubox76 commented May 18, 2026

This PR is built on top of #9904

(internal link) API proposal go/initializeapp-with-strings

Allows initializeApp() to be initialized with a string.

initializeApp() can currently be called with

  • an object representing the Firebase config
  • no arguments, if the config is available in a specific env var, a global var, or a cookie

Users often store the config as a JSON string when it needs to come from a secret or an environment variable, and then need to decode it, which can be error prone. To avoid this, users often store each property in separate secrets or environment variables, which can be cumbersome.

This change also accepts a JSON stringified string as an argument and automatically JSON.parses it, throwing an actionable error if the parse fails.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 18, 2026

🦋 Changeset detected

Latest commit: 5d80c59

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@firebase/app Minor
firebase Minor
@firebase/app-compat Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enables the initialization of FirebaseApp and FirebaseServerApp instances using JSON configuration strings, including necessary updates to the API surface, error handling for JSON parsing, and expanded test coverage. The review feedback identifies several areas for improvement, including correcting JSDoc parameter documentation, implementing safer type validation for parsed JSON objects, updating a misleading test description, and removing a duplicate test case.

Comment thread packages/app/src/api.ts Outdated
Comment thread packages/app/src/api.ts Outdated
Comment thread packages/app/src/api.ts Outdated
Comment thread packages/app/src/api.ts Outdated
Comment thread packages/app/src/api.test.ts Outdated
Comment thread packages/app/src/api.test.ts Outdated
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.

2 participants