Runtime Modes
Two modes matter for most apps: local mode and connected mode. A third, custom_endpoints, routes selected context and telemetry calls through your own proxy while Playbook delivery stays with RevTurbine.
Connected mode
Section titled “Connected mode”Connected mode is how you change monetization without a deploy. RevTurbine stores and versions your Playbook; the SDK in your app keeps a fresh local copy and decides from it.
What it gives you:
- Change without deploying. Edit plans, entitlements, targeting and prompts in the RevTurbine dashboard, with your coding agent, or through the CLI. Draft, review, launch. The SDK picks up the new release on its next refresh.
- Versioned Playbooks. Every launch is an immutable Release with history. Roll back by restoring any earlier one.
- Analytics. Conversion and usage analytics, so you can see what’s working. Growth adds deeper analytics and self-driving growth recommendations.
- Signals your app doesn’t hold. Billing status from Stripe, trial state, per-customer exceptions and end-user behavior follow the user. Caps and cooldowns hold across devices, and an exception applies wherever that user shows up.
What doesn’t change: the RevTurbine SDK runs inside your app, and on your backend where you verify. It evaluates entitlements and placements locally, as a pure function of your Playbook and the current user context. Connected mode changes where the Playbook and user state come from, not where decisions run. We add no latency, and our availability never affects your product.
In code: runtimeMode: RuntimeMode.Server (revturbine_server), with the browser’s publicKey or a trusted backend’s apiKey. Both load hosted Playbooks and evaluate locally. Backend sessions belong to one user and operation; keep server keys out of browser bundles. See Initialize the SDK and Server-Side Integration.
Local mode
Section titled “Local mode”Local mode ships the Playbook with your app. You version it in your own repo, and changing it is a deploy. No account, always free, and production-capable on its own. Every decision is made the same way as in connected mode.
In code: runtimeMode: RuntimeMode.LocalOnly (local_only) with localRuntime: { playbook }.
Which one
Section titled “Which one”- Getting started, building a demo, or shipping a Playbook that rarely changes? Local.
- Want to change monetization without deploying, see analytics, or set per-customer exceptions? Connected mode.
- Need context or telemetry calls to go through your own proxy? Connected mode, with
custom_endpoints.
Mode comparison
Section titled “Mode comparison”| Mode | Where the Playbook comes from | What RevTurbine provides | Required config |
|---|---|---|---|
Local (local_only) | Bundled with your app | Nothing at runtime; optional anonymous adoption beacon | localRuntime: { playbook } |
Connected (revturbine_server) | RevTurbine, cached locally and refreshed in the background | Playbook delivery and versioning; user state (billing, trials, exceptions, behavior); analytics | publicKey (and a clientSession route for server-derived state). tenantId and endpoint are optional |
Connected with custom endpoints (custom_endpoints) | RevTurbine, cached locally as in connected mode | Same as connected mode; selected context and telemetry calls use your endpoints | Connected-mode config + endpointOverrides |
Keep the Playbook intact
Section titled “Keep the Playbook intact”Use a Playbook checked into your app for local mode, or let the SDK retrieve the launched Playbook from RevTurbine in connected mode. Pass the validated artifact intact. An app endpoint that reshapes, filters or strips fields creates a different artifact from the one you validated.
endpointOverrides does not reroute Playbook delivery. Keep endpoint set to RevTurbine and override only the supported context and telemetry calls. See the endpoint reference for the complete list.
Where decisions run, and what is cached
Section titled “Where decisions run, and what is cached”In every mode the SDK evaluates entitlements and placements inside your app, from the Playbook it holds. No check and no placement decision makes a network call.
In revturbine_server mode the SDK fetches the launched Playbook at init, keeps it in memory, and re-checks for a new release at most once a minute — a launched Playbook is immutable per version, so polling more often would only waste requests. If a refresh fails, the SDK keeps the last-known-good Playbook and never throws. Before the first Playbook has arrived, an entitlement check denies with an infrastructure reason (config_unavailable) rather than guessing.
Set the mode with the typed RuntimeMode constant rather than a raw string:
import { RuntimeMode } from '@revturbine/sdk';// runtimeMode: RuntimeMode.LocalOnly | RuntimeMode.Server | RuntimeMode.CustomEndpointslocal_only makes no config or decisioning calls and does not send clickstream
events to RevTurbine ingest. The anonymous SDK init and error events
(sdk_init, sdk_error, resolution_failure) are the one network exception;
see SDK init and error events. Set
anonymousTelemetry: false (or previewMode: true for docs and examples) when
the process must make zero RevTurbine requests.
Copy-Paste Setup
Section titled “Copy-Paste Setup”import { initRevTurbine, RuntimeMode } from '@revturbine/sdk';import playbook from './revturbine.playbook.json';
// No account, key, tenant or endpoint: the Playbook is the whole configuration.// The one thing every mode needs is the user it evaluates for.const session = await initRevTurbine({ runtimeMode: RuntimeMode.LocalOnly, user: { id: 'user_123' }, localRuntime: { playbook, storageKey: 'my-app:revturbine-local-runtime', },});import { initRevTurbine, createServerRuntimeConfig } from '@revturbine/sdk';
const session = await initRevTurbine( createServerRuntimeConfig({ tenantId: 'tenant_abc', publicKey: 'rtk_…', // public key — safe in the browser user: { id: 'user_123' }, // required in every runtime mode }),);import { initRevTurbine, createCustomEndpointRuntimeConfig } from '@revturbine/sdk';
const session = await initRevTurbine( createCustomEndpointRuntimeConfig({ tenantId: 'tenant_abc', publicKey: 'rtk_…', // public key — safe in the browser user: { id: 'user_123' }, // required in every runtime mode endpointOverrides: { clientContext: 'https://proxy.example.com/revturbine/client-context', userContext: 'https://proxy.example.com/revturbine/user-context', trialStatus: 'https://proxy.example.com/revturbine/trial-status', ingestEvents: 'https://proxy.example.com/revturbine/track', }, }),);Add the context and UI your Playbook uses
Section titled “Add the context and UI your Playbook uses”Local mode needs no placeholder tenant, API key or endpoint, but like every mode it needs a user: user.id is required and an SDK without one is disabled. Add the plan and other context your rules depend on, resolve the CTA action types your Playbook authors, and optionally supply branding:
import { initRevTurbine, RuntimeMode } from '@revturbine/sdk';import playbook from './revturbine.playbook.json';
const session = await initRevTurbine({ runtimeMode: RuntimeMode.LocalOnly, localRuntime: { playbook }, user: { id: 'user_123', plan_handle: 'starter' }, uiPathResolvers: { view_plans: () => { window.location.assign('/pricing'); }, }, branding: { workspace_name: 'My app', theme: { colors: { primary: '#6366f1' } }, },});
// The async initializer returns a session; instance-only methods live on .sdk.const branding = session.sdk.getBranding();Use your actual plan handle and CTA action types. Branding is optional and merges over defaults. With React, pass the same options to RevTurbineProvider and let it initialize the SDK. See User Context, CTA actions and Theming for the individual options.
A bundled Playbook as a startup seed in connected mode
Section titled “A bundled Playbook as a startup seed in connected mode”localRuntime.playbook has two roles, decided by runtimeMode:
- No
runtimeMode, orlocal_only: the Playbook is the whole runtime. The SDK fills a placeholdertenantId,publicKeyandendpoint, and makes no hosted calls. - A connected
runtimeMode(RuntimeMode.ServerorRuntimeMode.CustomEndpoints): the Playbook is a startup seed. The SDK keeps exactly the options you pass, so a browser init with onlypublicKeyuses the hosted default endpoint and learns its tenant from the key, like an init without a seed. The seed answers entitlement and placement decisions immediately, the delivered Playbook replaces it when it arrives, and the seed stays in force if delivery fails (getPlaybookLoadFailure()says why).
import { initRevTurbine, RuntimeMode } from '@revturbine/sdk';import playbook from './revturbine.playbook.json'; // bundled snapshot
const session = await initRevTurbine({ publicKey: 'rtk_…', // no tenantId, no endpoint runtimeMode: RuntimeMode.Server, // connected: the Playbook is a seed localRuntime: { playbook }, user: { id: 'user_123' },});Analytics consent and the rest of the SDK
Section titled “Analytics consent and the rest of the SDK”Analytics is a separate concern from behavior. telemetry.consent and analytics: false stop the SDK reporting: clickstream events, including every placement_interaction (impression, dismissal, CTA click), are not sent. They never affect Playbook delivery, entitlement or placement decisions, dismissal cooldowns, suppression or presentation caps, so a connected-mode instance with consent denied still downloads your Playbook and enforces its caps. You do not need local_only to honor consent. See Events & Analytics.
Migrating from local to connected mode
Section titled “Migrating from local to connected mode”When you want dashboard-managed changes without deploying your app, switch the connection options. Local mode is also production-capable; your component code stays the same:
<RevTurbineProvider options={{ runtimeMode: RuntimeMode.LocalOnly, localRuntime: { playbook }, tenantId: process.env.REVTURBINE_TENANT_ID!, publicKey: process.env.REVTURBINE_PUBLIC_KEY!, runtimeMode: RuntimeMode.Server, user: { id: 'user_123', plan_handle: 'starter' }, }}>Provider Fallback Strategy
Section titled “Provider Fallback Strategy”Providers are for teams that supply their own facts — entitlement grants, user context — from more than one source. Decisions evaluate locally from the available Playbook. Loading or refreshing that snapshot can still fail; handle config_unavailable and choose an explicit freshness policy. Most apps configure no provider.
Available options:
provider: primary provider.providerFallbacks: ordered fallback provider list.providerFailureSlotBehavior:'invisible'(default) or'placeholder'.
Behavior:
- SDK calls primary provider first.
- If primary fails, SDK logs a warning and executes fallbacks in order.
- If all configured providers fail for a method, slots render hidden or placeholder output based on
providerFailureSlotBehavior.
Integration Checklist
Section titled “Integration Checklist”- Start with
local_onlyto validate your integration and placement slots. - For dashboard-managed changes and analytics, switch to
RuntimeMode.Serverand provide real credentials. - Re-check billing-critical actions on your server with the same Playbook — see Server-Side Integration.
- If you supply your own facts through providers, choose
providerFailureSlotBehaviorper surface.