Skip to main content

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?โ€‹