Skip to content

// Library

offline-queue

Holds API calls while a phone has no signal, then sends them in order once it does.

license
MIT
Install
npm install offline-queue
A city street seen from above at night, lit by street lamps

README.md

MIT

offline-queue is a 2 kB TypeScript queue for apps people use in the field. Requests made with no signal are saved on the device, then sent in the order they were made once the connection comes back.

Usage

tsx
import { createQueue } from "offline-queue"

const queue = createQueue({
  storage: "indexeddb",
  retry: { times: 5, backoff: 2000 },
})

// Works the same with or without signal
await queue.add(() => api.post("/jobs/42/photos", form))

What you get

  • Jobs saved to IndexedDB or AsyncStorage, so they survive an app restart
  • Sent in the order they were made, with retries and backoff
  • queue.size and an onSent hook, so the screen can show what is still waiting

Why it exists

It started on QPIMS, where installers upload job photos from basements and rooftops. Uploads were failing without a word, and the office never saw the work. The queue fixed that in a week.

No dependencies. It runs the same in React Native and in the browser.

More from the lab.

06Everything in the lab

// Start a project

Tell me what you are building.

Three quick picks so the first reply is useful. You finish the message on the contact page.

01What do you need?
02Rough budget

brief.ts

draft, not sent

export const brief = {

kind: null, // not picked yet

budget: null, // not picked yet

name: null, // not typed yet

}

or write to hello@bokoisaac.com

Nothing is sent from this page. Your picks are kept in this browser tab and wait for you on the contact form.