react-client-sdk icon indicating copy to clipboard operation
react-client-sdk copied to clipboard

Multiple environment support for react sdk.

Open chrisbrooks opened this issue 2 years ago • 4 comments

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

chrisbrooks avatar Mar 30 '22 01:03 chrisbrooks

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.

louis-launchdarkly avatar Apr 02 '22 00:04 louis-launchdarkly

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.

tappin-kr avatar Jun 05 '24 20:06 tappin-kr

+1

drewpc avatar Jun 05 '24 22:06 drewpc

@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?

drewpc avatar Jun 11 '24 18:06 drewpc