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

ngx-offline-sync

v1.1.0

Published

Offline HTTP request synchronization for Angular applications.

Readme

ngx-offline-sync

An Angular library that automatically saves HTTP requests when there is no internet connection and synchronizes them once the connection is restored.

Contents

Features

  • Automatically queues HTTP requests when there is no network connection
  • Persists the queue in IndexedDB
  • Automatically syncs the queue once the connection is restored
  • Processes requests sequentially
  • Retries failed requests
  • Tracks the status of each request
  • Supports POST, PUT, PATCH, and DELETE

Installation

npm install ngx-offline-sync

Setup

Add provideOfflineSync() and offlineSyncInterceptor to your application configuration:

import { ApplicationConfig } from '@angular/core';

import {
  provideHttpClient,
  withInterceptors,
} from '@angular/common/http';

import {
  provideOfflineSync,
  offlineSyncInterceptor,
} from 'ngx-offline-sync';

export const appConfig: ApplicationConfig = {
  providers: [
    provideOfflineSync(),

    provideHttpClient(
      withInterceptors([
        offlineSyncInterceptor,
      ]),
    ),
  ],
};

Once set up, the library manages the queue, storage, synchronization, and retries on its own. No additional registration of internal services is required.

Usage

Once set up, the library doesn't require any special API for sending requests. Just use the regular HttpClient:

this.http.post('/api/products', product).subscribe();
  • If an internet connection is available, the request is sent as usual.
  • If the connection is unavailable, the request is automatically added to the queue.

How it works

Internet available

HttpClient
    ↓
offlineSyncInterceptor
    ↓
HTTP request
    ↓
Server

The request is sent directly.

Internet unavailable

HttpClient
    ↓
offlineSyncInterceptor
    ↓
QueueService
    ↓
IndexedDB
    ↓
PENDING

The request is saved locally and waits for the connection to be restored.

Internet restored

NetworkStatusService
    ↓
SyncCoordinatorService
    ↓
SyncService
    ↓
SYNCING
    ↓
HTTP request
    ↓
COMPLETED

The queue is processed automatically.

Request statuses

Each request has one of the following statuses:

| Status | Description | |-------------|---------------------------------------| | PENDING | The request is waiting to be executed | | SYNCING | The request is being executed | | COMPLETED | The request was executed successfully | | FAILED | The request could not be executed |

Basic request lifecycle:

PENDING → SYNCING → COMPLETED

On error:

SYNCING → RetryPolicy → PENDING → Retry

If the request should no longer be retried:

SYNCING → FAILED

Retries

If synchronization fails, the library passes the error to the RetryPolicy.

The policy determines:

  • whether the request should be retried;
  • the delay before the next attempt;
  • when the request should be marked as FAILED.

Overall lifecycle:

SYNCING → Request failed → RetryPolicy → PENDING → Retry

After a successful execution:

PENDING → SYNCING → COMPLETED

If the number of attempts exceeds the allowed limit:

SYNCING → Request failed → FAILED

Architecture

The library is split into several core components:

NetworkStatusService
        │
        ▼
OfflineSyncInterceptor
        │
        ▼
QueueService
        │
        ▼
IndexedDbStorage
        │
        ▼
SyncCoordinatorService
        │
        ▼
SyncService
        │
        ├── RetryPolicy
        │
        └── HttpClient

Core components

offlineSyncInterceptor Intercepts HTTP requests and determines whether a request needs to be queued.

NetworkStatusService Tracks the state of the internet connection and notifies the library when it's restored.

QueueService Manages the request queue: adding, retrieving, updating, and removing items.

IndexedDbStorage Uses IndexedDB for persistent local storage of the queue.

SyncCoordinatorService Watches for the connection to be restored and triggers queue synchronization.

SyncService Retrieves requests from the queue, executes them via HttpClient, and updates their status.

RetryPolicy Defines the rules for retrying failed requests.

Roadmap

The project is under active development. Planned improvements include:

  • Support for configurable retry strategies
  • Extended queue configuration options
  • Request priority management
  • The ability to cancel and remove requests from the queue
  • Extended sync-state management
  • Improved error and network-state handling
  • Extended IndexedDB configuration options
  • Additional tools for monitoring the queue
  • Expanded test coverage
  • Improved documentation and usage examples

Limitations

  • Currently, the library is designed to sync the following HTTP methods: POST, PUT, PATCH, DELETE.
  • GET requests are not added to the offline queue.
  • The queue is stored locally in the browser's IndexedDB.

License

See LICENSE.