npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@monesh-tilavi/react-native-offline-sync

v1.0.2

Published

A production-ready offline-first sync engine for React Native that works as middleware with Axios.

Readme

React Native Offline Sync Engine

A production-ready offline-first sync engine for React Native that works as middleware with Axios.

Instead of replacing your API client, this library enhances it by automatically queuing failed requests (due to no internet) and retrying them when connectivity is restored.


🚀 Features

  • 📦 Automatic offline request queueing
  • 🔄 Auto retry when internet is back
  • ⚡ Axios interceptor support (no API change required)
  • 🌐 Network detection
  • 🧩 Pluggable storage (AsyncStorage, SQLite, MMKV)
  • 🧠 Retry & failure handling
  • 🪶 Lightweight and scalable

📦 Installation

npm install react-native-offline-sync

Install peer dependencies:

npm install axios @react-native-async-storage/async-storage @react-native-community/netinfo

🧠 How It Works

  1. Your app makes API calls using Axios
  2. If request fails due to no internet → it is automatically stored in queue
  3. When internet is restored → queued requests are retried
  4. No changes needed in existing API calls

⚙️ Setup

1. Create Axios instance

import axios from 'axios'

const api = axios.create({
  baseURL: 'https://api.example.com'
})

2. Setup Offline Sync Middleware

import {
  QueueManager,
  SyncProcessor,
  asyncStorageAdapter
} from 'react-native-offline-sync'

import { setupOfflineSync } from 'react-native-offline-sync/integrations'

const queueManager = new QueueManager(asyncStorageAdapter)

const syncProcessor = new SyncProcessor(queueManager, {
  baseUrl: 'https://api.example.com'
})

// attach middleware
setupOfflineSync(api, queueManager, syncProcessor)

🔥 Usage (No Change Required)

await api.post('/cart/add', { id: 1 })

👉 If offline → request is automatically queued 👉 If online → request works normally


🔄 Manual Sync (Optional)

await syncProcessor.processQueue()

⚙️ Advanced Configuration

const syncProcessor = new SyncProcessor(queueManager, {
  baseUrl: 'https://api.example.com',
  maxRetries: 3,
  retryDelay: 2000,

  onSuccess: (item, response) => {
    console.log('Synced:', item)
  },

  onError: (item, error) => {
    console.log('Failed:', item)
  }
})

🔧 Custom Request Executor (Axios Integration)

To fully use Axios for retry:

const syncProcessor = new SyncProcessor(queueManager, {
  executeRequest: (item) => {
    return api({
      url: item.endpoint,
      method: item.method,
      data: item.payload,
      headers: item.headers
    })
  }
})

🧩 Storage Adapters

Default:

import { asyncStorageAdapter } from 'react-native-offline-sync'

Custom adapter support:

export interface StorageAdapter {
  setItem(key: string, value: string): Promise<void>
  getItem(key: string): Promise<string | null>
  removeItem(key: string): Promise<void>
}

📁 Queue Structure

{
  "id": "unique_id",
  "endpoint": "/api/path",
  "method": "POST",
  "payload": {},
  "status": "pending",
  "retries": 0,
  "timestamp": 1710000000
}

🛠️ Future Roadmap

  • Conflict resolution
  • Optimistic UI updates
  • Background sync
  • Batch processing
  • Redux integration

🤝 Contributing

Pull requests and contributions are welcome.


📄 License

MIT License


👨‍💻 Author

Monesh Tilavi