Skip to content
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

initialize client with flags from server #489

Closed
nicksrandall opened this issue May 18, 2023 · 13 comments
Closed

initialize client with flags from server #489

nicksrandall opened this issue May 18, 2023 · 13 comments

Comments

@nicksrandall
Copy link

It would be great if I could initialize the client client (haha don't know what else to call it) with flag values that I got from the server.

FWIW, the launch darkly sdk allows you to pass in an option called "bootstrap" which is a list of all flags.

@cdruxerman
Copy link

Hi @nicksrandall thanks so much for submitting this. It's definitely on our radar and our product team is considering it.

Are there any use cases you currently have that are blocked without this?

@nicksrandall
Copy link
Author

It's a performance optimization. Without it our users pay a ~300ms penalty while they wait for the client to load flags.

@cdruxerman
Copy link

Hi @nicksrandall, for sure, definitely understand the need for the lowest latency possible.

For DevCycle we'd expect on average a 50ms response time for the JS SDK, unless you were using EdgeDB, which might bring it up to about 100ms. Are you seeing 300ms response times in your testing of the SDK?

@kenny-nguyen
Copy link

Hey @nicksrandall, chiming in to let you know the team is still looking into this. As Cobi mentioned, we generally expect a lower than 300ms response time for the JS SDK. Are you consistently seeing ~300ms on your end?

@rickyrattlesnake
Copy link

This would help with server-side rendered applications where the first load client-side is always going to return false from useIsDevcycleInitialized() forcing the server render to send a loading state HTML to avoid hydration issues.

@jsalaber
Copy link
Contributor

@rickyrattlesnake We do have this work in in our roadmap to do, although we do not have a timeline on when it might be completed.

@ajwootto
Copy link
Contributor

Hi @rickyrattlesnake @nicksrandall just wanted to let you know that an option to provide a config to the SDK has been added. It's called bootstrapConfig and expects to be provided the same config that would normally be returned from the API call to DevCycle's servers that the SDK normally makes clientside. This allows server rendered applications to perform that same call on the server and provide the config directly to the client in the response, skipping the initial config fetch and allowing for proper SSR hydration.

To make this process easier specifically in Next JS, we've also been working on a native Next JS SDK which is now available in beta:
https://www.npmjs.com/package/@devcycle/nextjs-sdk

the SDK supports both the pages router and the new App Router, and makes it easy to render content with DevCycle variables on both the server and client.

Hopefully these updates can address your needs, and apologies for the delay in getting this ready.

If your usecase for SSR does not include Next JS, happy to share more details about how you can set things up in your chosen framework to bootstrap the config.

If you get a chance to give these things a try, we'd love to hear any feedback or issues you encounter!

@ajwootto
Copy link
Contributor

Just another update to let you know that the Next.js has been fully released out of beta.

@nicksrandall
Copy link
Author

@ajwootto I'm currently using Remix framework (and not Next.js). Can you give some guidance on what needs to be passed to bootstrapConfig? And how I can get that value from the server SDK?

@ajwootto
Copy link
Contributor

ajwootto commented Apr 9, 2024

Hi @nicksrandall sorry to leave you waiting here, I was putting together a guide on how to do this and realized the experience isn't as smooth as it should be still. Working on a few SDK updates that should make it more painless to do bootstrapping in other frameworks, and I'll update here when those are complete. Thanks for your patience.

@nicksrandall
Copy link
Author

@ajwootto any update here?

@ajwootto
Copy link
Contributor

ajwootto commented May 3, 2024

Hi @nicksrandall thanks so much for your patience. We've added a new method to the Node.js SDK which can be used to obtain a boostrapping config to pass to the client. There's a new docs page for it describing the process, along with a small Remix example app showing all the pieces working together.

Please give it a try with the latest version of the Node SDK and let me know if it works for you. As this is a new feature we'd love to hear any thoughts, feedback or issues you encounter!

@ajwootto
Copy link
Contributor

Hey @nicksrandall I'm going to close this now as we've implemented bootstrapping to address this need. Let me know if it ends up working for you and feel free to open again if there are any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

6 participants