Platform Playbooks
Why This Page Exists
Use this page to pick the right integration model and follow the correct onboarding path without mixing runtime patterns.
Platform Decision Matrix
| Goal | Recommended Model | Why |
|---|---|---|
| Launch fastest on an existing storefront | CDN (<script>) | Zero framework wiring, auto-init, global API available immediately. |
| Keep strict lifecycle control in SPA/SSR app | npm (@selwise/widget) | Single-instance control with explicit init() and destroy(). |
| Integrate in mobile app (Expo/Bare RN) | React Native (@selwise/react-native) | Headless SDK, mobile key scopes, no DOM dependencies. |
Reuse global window.Selwise snippets | CDN or npm with exposeGlobal: true | Maintains global call style. |
| Build fully custom mobile UI for search/recommendations | React Native | Data APIs are exposed, rendering is app-owned. |
Recommended Customer Journey
- Complete Installation.
- Open the model-specific playbook:
- Run Verification.
- If any probe fails, use Integration Troubleshooting.
Migration Paths
CDN -> npm
- Remove CDN
<script>from base layout. - Install
@selwise/widget. - Create one shared runtime instance in your app shell.
- Keep
exposeGlobal: truetemporarily if legacywindow.Selwisecalls exist. - Move global calls to instance calls (
widget.track(...)) over time. - Run full verification probes.
Web -> React Native (Headless)
- Keep the same
siteKey. - Create mobile public API keys from dashboard with
mobile_readandmobile_writescopes. - Initialize
@selwise/react-nativewithapiKey. - Set screen context on navigation changes.
- Move event calls to
sdk.track(...)and flush strategically (sdk.flush()). - Replace widget rendering assumptions with your own RN UI using headless APIs.
npm -> CDN (Rollback / Simplification)
- Re-add canonical CDN script tag.
- Remove app-level runtime bootstrap code.
- Validate that required global calls still exist.
- Re-run verification probes for tracking, orders, and consent.
Guardrails
- Do not run CDN and npm runtime at the same time in the same web shell.
- Do not initialize multiple runtime instances per app shell.
- Do not ship mobile API keys with broader scopes than needed.
- Do not treat React Native SDK as a widget renderer (v1 is headless).