Skip to main content
Traffical SDKs resolve parameters locally inside your application. The SDK downloads a config bundle, evaluates everything in-process, and never blocks your code on a network call.

How the SDKs work

  1. 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.
  2. Resolve locally. When you call getParams (or decide), the SDK computes the user’s bucket from their context, evaluates targeting conditions, and returns the resolved values. Sub-millisecond, no network call.
  3. 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.
  4. Refresh automatically. The SDK periodically re-fetches the bundle (default: every 60s). ETag caching means unchanged bundles return 304 Not Modified and 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:
ModeBehaviourDefault for
bundleSDK fetches the bundle and resolves locally. Sub-millisecond.Node, PHP, web browser, React, Svelte
serverSDK calls Traffical for each resolution. Fresh state, higher latency.React Native
You usually want 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

PackageEnvironmentDefault mode
@traffical/nodeServer (Node.js / Bun)bundle
traffical/sdkServer (PHP 8.1+)bundle
@traffical/js-clientBrowser, framework-freebundle
@traffical/reactReact (browser, RSC)bundle
@traffical/svelteSvelte + SvelteKitbundle
@traffical/react-nativeiOS / Android via React Nativeserver
All SDKs share a common core that implements bundle parsing, bucket hashing, condition evaluation, and resolution — @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 + useTraffical hook.
  • SvelteKit or Svelte 5@traffical/svelte. SSR-friendly with loadTrafficalBundle().
  • Plain browser app (Vue, no framework, vanilla)@traffical/js-client. Direct API.
  • Mobile (iOS / Android via React Native)@traffical/react-native.
You can mix server and client SDKs in the same app. A common pattern is to resolve on the server for the initial render (no flash of original content) and let the client SDK handle interactive updates. See SSR patterns.

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.