JavaScript SDK Overview
The Resync JavaScript SDK is a powerful library for dynamic content management, remote configuration, and in-app campaigns. It works seamlessly across JavaScript, React Native, and Expo applications.
Featuresโ
- ๐ Remote Configuration - Manage app configs remotely without code deployments
- ๐งช In-app Campaigns - Run campaigns with automatic variant assignment and tracking
- ๐จ Dynamic Content Management - Fetch and render content views from your dashboard
- ๐ Event Logging - Track custom events and user interactions
- ๐พ Smart Caching - Automatic environment-based caching (6h production, 0ms development)
- ๐ Real-time Updates - Subscribe to configuration changes with callback support
- ๐ฑ Cross-Platform - Works with vanilla JavaScript, React Native, and Expo
- ๐ง TypeScript Support - Full TypeScript definitions included
- ๐ฏ User Targeting - Set user attributes for personalized experiences
Installationโ
npm install resync-javascript
# or
yarn add resync-javascript
Quick Startโ
1. Initialize Resyncโ
import Resync from 'resync-javascript';
await Resync.init({
key: 'your-api-key',
appId: 7,
callback: async (config) => {
console.log('Resync initialized with config:', config);
},
storage: localStorage, // or AsyncStorage for React Native
environment: 'production',
});
2. Get Remote Configurationโ
const featureEnabled = Resync.getConfig('FEATURE_FLAG');
const apiEndpoint = Resync.getConfig('API_ENDPOINT');
console.log('Feature enabled:', featureEnabled);
3. Run Campaignsโ
const variant = await Resync.getVariant('homepage_experiment');
if (variant === 'variant_a') {
// Show variant A
} else {
// Show variant B
}
4. Log Eventsโ
Resync.logEvent({
eventId: 'evt_button_clicked',
metadata: {
buttonName: 'signup',
screen: 'homepage',
},
});
5. Get Content Blocksโ
const contentViews = Resync.getContent();
const welcomeCard = contentViews.find(
(view) => view.name === 'HomeWelcomeCard'
);
console.log('Welcome card content:', welcomeCard);
Platform Supportโ
- โ JavaScript (ES6+) - Modern JavaScript environments
- โ React Native - iOS and Android apps
- โ Expo - Managed and bare workflows
- โ Node.js - Server-side JavaScript (with compatible storage)
- โ Web Browsers - Chrome, Firefox, Safari, Edge
TypeScript Supportโ
The library includes comprehensive TypeScript definitions:
import Resync, {
InitOptions,
AppConfig,
ContentView,
Experiment,
AppEvent,
} from 'resync-javascript';
const options: InitOptions = {
key: 'your-api-key',
appId: 7,
storage: localStorage,
environment: 'production',
};
await Resync.init(options);
Next Stepsโ
Need Help?โ
- Check the API Reference for detailed documentation
- Browse code examples
- Email hello@getresync.com