statsig-io / statsig-feedback

Issue Tracker for Statsig. Leave your feedback on anything we do!
5 stars 0 forks source link

Svelte/SvelteKit official sdk support #23

Open smblee opened 2 years ago

smblee commented 2 years ago

With Svelte also gaining some popularity, it would be nice to see some official documentation around Svelte (or the nextJS equivalent sveltekit). Svelte should be pretty straightforward, but sveltekit might be a bit more tricky as it can both be SSR/CSR similar to NextJS.

As a reference, LaunchDarkly currenlty does have an official tutorial/sdk on svelte/sveltekit (https://docs.launchdarkly.com/guides/platform-specific/svelte)

vijaye-statsig commented 2 years ago

@tore-statsig what do you think?

tore-statsig commented 2 years ago

Right now we are focused on support for Flutter/dart and elixir/erlang, but we can look into Svelte after those!

It does look like the LaunchDarkly link your provided just gives some direction around how to use their js client sdk and node-js server sdk with the svelte framework, so this shouldnt require a new SDK.

For now, I think you should be able to follow similar steps with Statsig in terms of initializing the SDK and using it on the client side with Svelte.

I think our SSR steps/using SvelteKit will differ more.

smblee commented 2 years ago

Gotcha. Yea we are currently using SvelteKit and it was actually pretty finicky to get the hybrid (CSR/SSR) solution working correctly (especially with the sveltekit's load function). So for now, we are thinking of doing SSR only and hydrating down to CSR until we can think of a better solution.

tore-statsig commented 2 years ago

Did you look at the statsig SSR info for the node sdk? The node server SDK has a function that will generate the initialize values for a user:

https://docs.statsig.com/server/nodejsServerSDK#ssr

And then the js-client sdk takes that in.

Right now, we only document the flow for react, but the react SDK just uses our js sdk internally. Here's the call to set the values for the client SDK

https://github.com/statsig-io/react-sdk/blob/main/src/StatsigSynchronousProvider.tsx#L62

smblee commented 2 years ago

Was able to get something implemented but it was definitely a bit complex to get working. Feel free to close, but might be worth having it be opened for official support? (at least documentation)

tore-statsig commented 2 years ago

Yeah we will keep it open for now. Glad you got something working!