braze-inc / braze-web-sdk

Public repo for the Braze Web SDK
https://www.braze.com
Other
70 stars 25 forks source link

[Feature]: Support SSR frameworks as an ES6 module #147

Open bscaspar opened 7 months ago

bscaspar commented 7 months ago

What problem are you facing?

I would like to import the Braze web-sdk as an ES6 module. The current client-side only implementation requires workarounds to work with SSR frameworks, as documented in #103, #110, and #117.

Using these workarounds just to import Braze increases code complexity and increases maintenance time and effort.

SSR frameworks are some of the most popular web frameworks. Please support them!

Workarounds

Documented in #103, #110, and #117.

Ideal Solution

import { initialize, openSession, changeUser, [...etc] } from '@braze/web-sdk';

...
initialize(key);
openSession();
chaangeUser(userId);

Other Information

No response

davidbielik commented 7 months ago

Hi @bscaspar thanks for raising this - definitely great feedback and something we'll consider for a future major version. Right now the SDK is tightly coupled with browser APIs but we're exploring ways to make the SDK work in a server environment like SSR. We don't have a timeline we can share, but will keep this updated once we make any notable progress.