launchdarkly / react-client-sdk

LaunchDarkly Client-side SDK for React.js
Other
81 stars 67 forks source link

Multiple environment support for react sdk. #127

Open chrisbrooks opened 2 years ago

chrisbrooks commented 2 years ago

Is your feature request related to a problem? Please describe. We have multiple LD projects but want to pull some or all of them in with just one react SDK. You offer this support for react native and mobile: https://docs.launchdarkly.com/sdk/features/multiple-environments#android

Describe the solution you'd like Ideally provide multiple environments support for react sdk.

Describe alternatives you've considered I would like to know if there is any solutions for this even if not out the box

louis-launchdarkly commented 2 years ago

Hello @chrisbrooks, thank you for reaching out to us. I know that the multi-environment feature is currently not in JS SDK, so React SDK does not have build-in support yet.

As a workaround, if you don't mind digging into instantiating the JS SDK yourself, there is no problem if you instantiate multiple LDClients in JS SDK (to connect to your environment). Maybe you can instantiate multiple LDClients in React? You probably need to make sure the clients don't overwrite each other, so you may not able to use asyncWithLDProvider directly.

tappin-kr commented 1 month ago

Bumping this thread. Wondering if there might be an opportunity to add this ability, or like op posted, maybe post an example for a workaround that can be implemented.

drewpc commented 1 month ago

+1

drewpc commented 1 month ago

@louis-launchdarkly

Hello @chrisbrooks, thank you for reaching out to us. I know that the multi-environment feature is currently not in JS SDK, so React SDK does not have build-in support yet.

As a workaround, if you don't mind digging into instantiating the JS SDK yourself, there is no problem if you instantiate multiple LDClients in JS SDK (to connect to your environment). Maybe you can instantiate multiple LDClients in React? You probably need to make sure the clients don't overwrite each other, so you may not able to use asyncWithLDProvider directly.

Would LaunchDarkly support a pull request with an asyncWithCustomLDProvider implementation that has a client & provider object passed in to address this use case?