How the SDKs work
- Fetch the bundle. On startup the SDK fetches the config bundle for your (project, environment) pair. The bundle is a single JSON document containing every parameter, layer, and policy.
- Resolve locally. When you call
getParams(ordecide), the SDK computes the user’s bucket from their context, evaluates targeting conditions, and returns the resolved values. Sub-millisecond, no network call. - Track events in the background. Exposure and decision events are emitted automatically. Track events you emit explicitly are batched and shipped without blocking the calling code.
- Refresh automatically. The SDK periodically re-fetches the bundle (default: every 60s). ETag caching means unchanged bundles return
304 Not Modifiedand cost almost nothing.
Graceful degradation
If the bundle hasn’t loaded yet — or if Traffical is unreachable entirely — the SDK returns the defaults you passed in code. Your app keeps working. Traffical can only raise the ceiling, never lower the floor.Evaluation modes
Most SDKs support two evaluation modes:| Mode | Behaviour | Default for |
|---|---|---|
bundle | SDK fetches the bundle and resolves locally. Sub-millisecond. | Node, PHP, web browser, React, Svelte |
server | SDK calls Traffical for each resolution. Fresh state, higher latency. | React Native |
bundle. Use server when caching a full bundle isn’t reasonable (very limited memory, very rare resolutions) or for per-entity adaptive policies that need the freshest possible weights.
See how it works for details.
Available SDKs
| Package | Environment | Default mode |
|---|---|---|
@traffical/node | Server (Node.js / Bun) | bundle |
traffical/sdk | Server (PHP 8.1+) | bundle |
@traffical/js-client | Browser, framework-free | bundle |
@traffical/react | React (browser, RSC) | bundle |
@traffical/svelte | Svelte + SvelteKit | bundle |
@traffical/react-native | iOS / Android via React Native | server |
@traffical/core for the TypeScript SDKs, mirrored by the PHP and Swift engines against the same language-agnostic spec. Whichever language or framework you use, the same parameter resolves to the same allocation for the same user.
Picking an SDK
- Node.js / Bun backend →
@traffical/node. Server runtime, in-memory bundle, sub-ms resolution. - PHP backend (Laravel, Symfony, plain PHP-FPM) →
traffical/sdk. Local resolution, PSR-first, events flushed after the response. - React single-page app or RSC →
@traffical/react. Provider +useTrafficalhook. - SvelteKit or Svelte 5 →
@traffical/svelte. SSR-friendly withloadTrafficalBundle(). - Plain browser app (Vue, no framework, vanilla) →
@traffical/js-client. Direct API. - Mobile (iOS / Android via React Native) →
@traffical/react-native.
Source code
The TypeScript SDK packages live in a public repository at github.com/traffical/js-sdk, and the PHP SDK at github.com/traffical/php-sdk. Both are MIT-licensed and gated on a shared, language-agnostic conformance spec so bucketing is identical across languages. The@traffical/cli lives in a separate public repository.
Next steps
Node.js
Server-side SDK reference.
PHP
Server-side SDK for PHP 8.1+.
React
Provider, hooks, SSR.
Svelte
Stores, context, SvelteKit.
React Native
iOS / Android with cold-start strategy.