JavaScript SDK Installation
Learn how to install the Resync JavaScript SDK for your web or Node.js application.
Requirements
- Node.js v16 or higher
- npm or yarn package manager
Installation
Using npm
npm install resync-javascript
Using yarn
yarn add resync-javascript
Verify Installation
import Resync from 'resync-javascript';
console.log(Resync); // Should output the Resync object
Storage Configuration
The SDK requires a storage adapter for caching. Choose based on your platform:
Browser (Web)
import Resync from 'resync-javascript';
await Resync.init({
key: 'your-api-key',
appId: 7,
storage: localStorage, // or sessionStorage
environment: 'production',
});
React Native
import Resync from 'resync-javascript';
import AsyncStorage from '@react-native-async-storage/async-storage';
await Resync.init({
key: 'your-api-key',
appId: 7,
storage: AsyncStorage,
environment: 'production',
});
Custom Storage Adapter
You can implement your own storage adapter:
const customStorage = {
async getItem(key) {
// Your implementation
},
async setItem(key, value) {
// Your implementation
},
async removeItem(key) {
// Your implementation
},
async clear() {
// Your implementation
},
};
await Resync.init({
key: 'your-api-key',
appId: 7,
storage: customStorage,
environment: 'production',
});