react-offline-support-kit

1.0.0 • Public • Published

React Offline support kit

React Offline Support is a library designed to help developers add offline support to React.js/Next.js applications seamlessly. It provides features such as data synchronization, offline caching, and conflict resolution, enabling users to continue using the application even when they're not connected to the internet.

Installation

You can install the package via npm:

npm install react-offline-support-kit

Usage

  1. Offline Support Toolkit The Offline Support Toolkit provides Redux store configuration and action creators for managing the offline queue.

React Usage:

// Import the store and action creators
import { store, addToQueue, removeFromQueue } from "react-offline-support";

// Example usage
store.dispatch(addToQueue({ type: "ADD_TODO", payload: "Test todo" }));
store.dispatch(removeFromQueue());
  1. Higher-Order Component (HOC)

    The WithOfflineSupport Higher-Order Component (HOC) adds offline support to React components, enabling them to synchronize data when the network connection is restored.

React Usage:

// Import the HOC
import withOfflineSupport from "react-offline-support";

// Wrap your component with the HOC
const OfflineComponent = withOfflineSupport(MyComponent);

Example

Here's a basic example of using the package:

React.js Usage:

import React from "react";
import ReactDOM from "react-dom";
import { Provider } from "react-redux";
import { store } from "react-offline-support";
import withOfflineSupport from "react-offline-support";

// Define your functional component
const MyApp = () => {
  return <div>My App</div>;
};

// Add offline support to your functional component
const OfflineApp = withOfflineSupport(MyApp);

// Render the app with Redux provider
ReactDOM.render(
  <Provider store={store}>
    <OfflineApp />
  </Provider>,
  document.getElementById("root")
);

Package Sidebar

Install

npm i react-offline-support-kit

Weekly Downloads

0

Version

1.0.0

License

none

Unpacked Size

16.5 kB

Total Files

15

Last publish

Collaborators

  • thanushkumarrd