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

react-native-simple-queue

v0.1.2

Published

Offline request queue for React Native

Readme

React Native Simple Queue 🚀

npm version License Platform

Offline-first, persistent request queue for React Native.

This library automatically queues API requests when the user is offline and processes them when the internet connection is restored. It persists the queue to AsyncStorage, so requests are not lost even if the app is closed.

✨ Features

  • 🔌 Offline First: Queues requests automatically when there is no internet.
  • 💾 Persistent: Uses AsyncStorage to save requests (won't be lost on app restart).
  • 🔄 Auto Sync: Easy integration with NetInfo to auto-retry when online.
  • 📘 TypeScript: Fully typed for excellent developer experience.
  • 🪶 Lightweight: Zero bloat, simple logic.

📦 Installation

npm install react-native-simple-queue

Peer Dependencies

You need to install these packages if you haven't already:

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

🚀 Usage

1. Setup the Listener

In your root component (e.g., App.tsx), listen for connection changes to process the queue automatically.

import React, { useEffect } from 'react';
import NetInfo from '@react-native-community/netinfo';
import { queue } from 'react-native-simple-queue';

export default function App() {
  useEffect(() => {
    const unsubscribe = NetInfo.addEventListener(state => {
      if (state.isConnected) {
        // Internet is back! Process the queue.
        queue.processQueue()
          .then(sentItems => {
            if (sentItems.length > 0) {
              console.log('Synced items:', sentItems);
            }
          });
      }
    });
    return () => unsubscribe();
  }, []);

  return <YourApp />;
}

2. Add a Request

Replace your standard fetch or axios calls with queue.addRequest.

import { queue } from 'react-native-simple-queue';

const sendData = async () => {
  const response = await queue.addRequest(
    'https://api.example.com/posts',
    'POST',
    { title: 'Hello World', userId: 1 },
    { Authorization: 'Bearer token123' } // Optional headers
  );

  if (response.queued) {
    console.log('User is offline. Request has been queued!');
  } else {
    console.log('Success! Response from server:', response);
  }
};

📚 API Reference

queue.addRequest(url, method, body, headers)

Adds a request to the queue (if offline) or sends it immediately (if online).

| Param | Type | Description | |---|---|---| | url | string | The API endpoint URL. | | method | string | HTTP Method (GET, POST, PUT, DELETE, etc.). | | body | any | The payload (automatically stringified). | | headers | object | Optional request headers. |

queue.processQueue()

Manually triggers the processing of the queue. It checks for internet connection first. Returns a Promise that resolves to an array of successfully sent items.

🤝 Contributing

Contributions are welcome! Please see CONTRIBUTING.md for details.

📄 License

MIT © Aziz