Platform Requirements
- Roku OS
- js
- Performance
The GrowthBook SDK supports all modern Roku devices and OS versions:
- Minimum OS Version: Roku OS 9.0+
- Recommended: Roku OS 9.2+ (for AES encryption support)
- Tested on: Roku OS 9.0 - 12.x
- ✅ Roku Ultra (all versions)
- ✅ Roku Streaming Stick (all versions)
- ✅ Roku Express
- ✅ Roku Premiere
- ✅ Roku TV
- ✅ Legacy devices (Roku 2, Roku 3)
Installation
Manual Installation (Recommended)
- Download
GrowthBook.brsfrom the GitHub repository. - Copy it to your channel’s
source/directory:
Installation with ropm
If you are using ropm for dependency management:Quick Usage
Step 1: Initialize the SDK
Initialize GrowthBook once when your channel starts. Use a singleton pattern to reuse the instance throughout your app.Step 2: Use Feature Flags
Once initialized, access the GrowthBook instance anywhere in your channel:Loading Features
The GrowthBook SDK provides multiple strategies for loading feature flags, allowing you to choose between automated feature loading at the init or using it in offline mode.Automated Loading
At the time of initialization, the SDK automatically fetches features from the GrowthBook API when you provideapiHost and clientKey:
- When
init()is called, the SDK makes an HTTP request to{apiHost}/api/features/{clientKey} - Features are cached in memory for the lifetime of the instance
- All subsequent feature evaluations use the cached data (no additional network calls)
- Features are loaded once when
init()is called - No automatic background refresh is supported for now.
- Roku Limitation: Unlike web SDKs, Roku does not support Server-Sent Events (SSE) for real-time streaming updates
- To get updated features, you must reinitialize the GrowthBook instance (typically on app restart)
- For real-time updates, implement a manual refresh mechanism:
Offline Mode
For scenarios where network access is unavailable or you want to embed features directly in your channel, use offline mode.- ✅ Testing and development without GrowthBook account
- ✅ Regions with unreliable or no network connectivity
- ✅ Regulatory requirements preventing external API calls
- ✅ Feature flags that rarely change and can be bundled with app
- ✅ Fallback strategy for network failures
- ✅ Kiosk or offline-first applications
- ❌ Features must be updated via channel deployment (sideload or store update)
- ❌ Cannot change feature values remotely without app update
- ❌ No real-time experimentation updates
Configuration Options
Required Options
At minimum, provide eitherclientKey OR features:
All Configuration Options
Instance Management (Singleton Pattern)
Recommended: Create one instance and reuse it globally.Updating Attributes
Update user attributes without recreating the instance:Feature Flags
There are 2 main methods for evaluating features:isOn and getFeatureValue:
Boolean Flags
Simple on/off toggles:Feature Values
Get configuration values with type-safe fallbacks:JSON Configuration
Complex objects for advanced configuration:Experimentation (A/B Testing)
There is nothing special you have to do for feature flag experiments. Just evaluate the feature flag like you would normally do. If the user is put into an experiment as part of the feature flag, it will call thetrackingCallback automatically in the background.
Tracking Callbacks
GrowthBook provides two types of callbacks to monitor feature usage and experiment exposure:Experiment Tracking Callback
ThetrackingCallback is fired when a user is placed into an experiment. Use this to send experiment exposure events to your analytics platform (Segment, Mixpanel, Google Analytics, etc.).
experiment object:
key(string) - Experiment identifiervariations(array) - List of possible variationsweights(array) - Traffic allocation weightshashVersion(integer) - Hash algorithm versionnamespace(array) - Namespace for traffic allocation
result object:
experimentId(string) - Experiment keyvariationId(integer) - Assigned variation index (0-based)value(dynamic) - Actual variation valueruleId(string) - ID of the rule that triggeredsource(string) - Always"experiment"for tracking callbackon(boolean) - Whether feature is enabledkey(string) - Feature key
- User enters an experiment (assigned to a variation)
- Only fires ONCE per unique experiment + user combination (de-duplicated)
- Features with no experiments
- Users excluded from experiments
- Forced variations
Feature Usage Callback
TheonFeatureUsage callback is fired on every feature evaluation, not just experiments. Use this for high-level usage tracking or debugging.
featureKey(string) - The key of the feature being evaluatedresult(object) - Complete evaluation result (same structure asevalFeature())
- Every call to
isOn(),getFeatureValue(), orevalFeature() - Includes all sources:
"defaultValue","force","experiment","unknownFeature"
Comparison
Hashing and Consistent Assignment
GrowthBook uses deterministic hashing to ensure users get consistent variation assignments. This is critical for accurate A/B testing.How Hashing Works
When a user is evaluated for an experiment:- Hash Input: The SDK combines the user’s
idattribute with the experiment key - Generate Hash: Uses FNV-1a hashing algorithm to produce a number between 0 and 1
- Map to Bucket: The hash maps to a specific variation based on traffic weights
- Return Variation: User is assigned to that variation consistently
Hash Attribute
By default, GrowthBook uses theid attribute for hashing. You can customize which attribute to use with the hashAttribute setting in your experiment rules.
Default Behavior:
hashAttribute in your experiment rule:
When to Use Custom Hash Attributes
Use custom hash attributes when:
Example: Device-Level Experiment
Debugging Hash Assignments
Enable dev mode to see hash calculations:Production Best Practices
Error Handling
Always check if GrowthBook initialized successfully:Performance Optimization
Avoid calling feature checks in tight loops:Troubleshooting
1) SDK Not Loading
GrowthBook() returns invalid
- Verify
GrowthBook.brsis insource/directory - Check file name is exactly
GrowthBook.brs(case-sensitive) - Ensure no syntax errors in the file
- Try compiling channel to see errors
2) Features Not Loading
init() returns false
- Check
clientKeyis correct - Verify network connectivity
- Test API endpoint:
https://cdn.growthbook.io/api/features/YOUR_KEY - Enable dev mode:
enableDevMode: trueto see error logs - Provide fallback features for offline resilience
3) Version Targeting Not Working
Version-based rules don’t match- Use semantic versioning:
"2.1.0"not"2.1"or"v2.1.0" - Verify
appVersionattribute is set correctly - Test version operators in GrowthBook dashboard preview
- Enable dev mode to see evaluation logs
4) Inconsistent Variations
User sees different variations across sessions- Ensure
idattribute is stable (use device ID, not random) - Don’t use
Rnd()or random values forid - Verify
idis set before evaluating features - Check that you’re not creating multiple GrowthBook instances
5) Experiments Show Wrong Traffic Split
50/50 split when expecting 70/30- Verify weights in GrowthBook dashboard match expectations
- Ensure weights array length matches variations count
- Test with multiple user IDs to verify distribution
- Check experiment is published and active
Limitations
- ❌ No Server-Sent Events (SSE) streaming support (Roku limitation)
- ❌ No Visual Editor experiments (SceneGraph only)
- ❌ AES decryption requires Roku OS 9.2+ (
roEVPCiphercomponent) - ❌ Network requests are asynchronous only (no sync API)

