Skip to content

Quick Start

Get started with the Ascend React Native SDK in just a few steps.


import React, { useEffect } from 'react';
import { Ascend } from '@dreamhorizonorg/ascend-react-native';
const App = () => {
useEffect(() => {
setupAscendSDK();
}, []);
const setupAscendSDK = async () => {
// 1. Initialize with configuration
const result = await Ascend.init({
// Client authentication and user settings
clientConfig: {
apiKey: 'your-api-key', // Required: Your Ascend API key
userId: 'user-123', // Optional: Set user during initialization
environment: 'production', // Optional: 'development' | 'staging' | 'production'
enableDebugLogging: false, // Optional: Enable debug logs for troubleshooting
},
// Base HTTP configuration
httpConfig: {
apiBaseUrl: 'https://your-api-url.com', // Required: Your API base URL
},
// Enable experiments plugin for feature flags and A/B testing
plugins: [
{
name: 'EXPERIMENTS',
config: {
// HTTP settings specific to experiments
httpConfig: {
apiBaseUrl: 'https://your-api-url.com',
apiEndpoint: '/v1/allocations/',
headers: {
'x-experiment-keys': 'your-experiment-key', // Your experiment keys
},
},
// Default values used as fallback when API is unavailable
defaultValues: {
'button_color': {
color: 'blue',
enabled: true,
size: 'medium',
},
'new_feature': {
enabled: false,
},
},
// Caching and behavior settings
enableCaching: true, // Enable offline caching
shouldFetchOnInit: true, // Fetch experiments on initialization
shouldRefreshDRSOnForeground: false, // Auto-refresh when app comes to foreground
},
},
],
});
// 2. Check initialization status
if (result.success) {
console.log('✅ Ascend SDK initialized successfully');
// 3. Set a user (required for experiments)
await Ascend.setUser('user-123');
} else {
console.error('❌ Failed to initialize Ascend SDK:', result.error);
}
};
return (
// Your app components
);
};

import { Experiments } from '@dreamhorizonorg/ascend-react-native';
// Get string value
const buttonColor = await Experiments.getStringFlag('button_color', 'color');
console.log('Button color:', buttonColor);
// Get boolean value
const isEnabled = await Experiments.getBooleanFlag('feature_toggle', 'enabled');
console.log('Feature enabled:', isEnabled);
// Get number value
const maxRetries = await Experiments.getNumberFlag('retry_config', 'max_attempts');
console.log('Max retries:', maxRetries);
// Get all variables for an experiment
const allVars = await Experiments.getAllVariables('button_color');
console.log('All variables:', allVars);

import { Experiments } from '@dreamhorizonorg/ascend-react-native';
// Fetch experiments with new default values
await Experiments.fetchExperiments({
'button_color': {
color: 'blue'
}
});
// Refresh all experiments using predefined defaults
await Experiments.refreshExperiment();

Coming soon…