-
Notifications
You must be signed in to change notification settings - Fork 8
feat: add ability to bootstrap flags on server and populate clients #475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
@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 |
Offline is a good solution |
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:
README.md
on how to use the newbootstrappedFlags
option for SSR, including benefits and usage examples.bootstrappedFlags
property to theInitOptions
and a newInitOptionsBootstrapped
type inclient.ts
, allowing the client to be initialized with pre-fetched flags. [1] [2]ReflagClient
andFlagsClient
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:
InitOptionsBootstrapped
,FetchedFlags
) and updated context types for clarity and better API documentation. [1] [2] [3] [4] [5]Testing and validation:
Version bump:
1.2.0
to reflect the new feature.