Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Swiftwork
Copy link
Contributor

@Swiftwork Swiftwork commented Sep 12, 2025

This pull request adds support for bootstrapping the Reflag browser SDK with pre-fetched flag data, enabling faster initial rendering and improved SSR performance. The changes introduce a new bootstrappedFlags option, update initialization logic to handle bootstrapped clients, and include documentation and tests to cover the new behavior.

Server-side rendering and bootstrapping support:

  • Added documentation in README.md on how to use the new bootstrappedFlags option for SSR, including benefits and usage examples.
  • Introduced the bootstrappedFlags property to the InitOptions and a new InitOptionsBootstrapped type in client.ts, allowing the client to be initialized with pre-fetched flags. [1] [2]
  • Updated ReflagClient and FlagsClient constructors and initialization logic to recognize and properly handle bootstrapped flags, skipping network requests when flags are already provided. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

Type and API improvements:

  • Exported new types (InitOptionsBootstrapped, FetchedFlags) and updated context types for clarity and better API documentation. [1] [2] [3] [4] [5]

Testing and validation:

  • Added tests to verify that bootstrapped clients skip flag fetching and initialization, ensuring correct behavior for SSR use cases.
  • Updated existing tests to reflect new error handling when re-initializing an already initialized flags client.

Version bump:

  • Bumped the package version to 1.2.0 to reflect the new feature.

@Swiftwork Swiftwork self-assigned this Sep 12, 2025
@Swiftwork Swiftwork added the enhancement New feature or request label Sep 12, 2025
Copy link
Contributor

@roncohen roncohen left a comment

Choose a reason for hiding this comment

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

would be nice with examples of how to use boostrapped flags in the browser, react and vue READMEs. Tip for next time: when building libraries like these it often makes sense to start with the README examples before writing the code to make sure the DX drives the implementation instead of the other way around.

@Swiftwork Swiftwork marked this pull request as ready for review September 16, 2025 14:49
@Swiftwork
Copy link
Contributor Author

Swiftwork commented Sep 16, 2025

@roncohen @pavkam any suggestion as to what we should do here https://github.com/reflagcom/javascript/actions/runs/17769720270/job/50502261309?pr=475#step:7:163? The nextjs wants to build the bootstrap demo with a secret key. Not sure if we should supply one to github actions, somehow disable the build, or do some offline stuff?

edit: I think offline mode will work fine for CI

@roncohen
Copy link
Contributor

@roncohen @pavkam any suggestion as to what we should do here https://github.com/reflagcom/javascript/actions/runs/17769720270/job/50502261309?pr=475#step:7:163? The nextjs wants to build the bootstrap demo with a secret key. Not sure if we should supply one to github actions, somehow disable the build, or do some offline stuff?

edit: I think offline mode will work fine for CI

sounds good

@pavkam
Copy link
Contributor

pavkam commented Sep 17, 2025

Offline is a good solution

@Swiftwork Swiftwork marked this pull request as draft September 19, 2025 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants