SDK Overview
Use @usesophi/sophi-web-sdk to embed the Sophi assistant in your storefront and handle widget events in your application code.
Note
Keep script loading and consent management separate from widget configuration.
If you use GTM, GTM should only load the SDK script after consent; initialization should stay in your app code.
What this SDK provides
- Framework-agnostic widget initialization
- Browser script support via
window.SophiWebSDK - Typed events for commerce actions
- Runtime methods for user/cart updates and widget lifecycle
Public API surface
- Class:
SophiWidget - Init:
await widget.init(config) - Events:
ready,add_to_cart,send_to_checkout,error - Methods:
on,off,updateUserCart,show,hide,isReady,destroy
Documentation map
Install the SDK from npm.
Load the SDK via GTM after consent and initialize in app code.
Configure SophiWidget safely and correctly.
Listen and respond to widget events in your app.
Runtime methods and lifecycle operations.
Prevent accidental secret exposure and unsafe integration.