Skip to content

local-first-web/state

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

@localfirst/state logo

@localfirst/state is an automatically replicated Redux store that gives your app offline capabilities and secure peer-to-peer synchronization superpowers.

๐Ÿšง Work in progress

Why

Distributed, offline-first technologies are promising for a lot of reasons, but they're unfamiliar to most web application developers. This library provides offline storage and peer-to-peer synchronization capabilities, and exposes them via a familiar Redux store that can be used in a vanilla JS, React, or Electron application.

๐Ÿก’ Read more

What

This library provides two services:

  • Data replication & synchronization, using the Automerge library
  • Persistence to a local or remote data store. You can use the provided adapters for IndexedDb or MongoDb, or provide your own.

๐Ÿก’ Read more

How

Example apps

Two demo React applications are included:

todo

An implementation of TodoMVC

To run: yarn dev:todo:start

grid

A simple table editor

To run: yarn dev:grid:start

Getting started

yarn add @localfirst/state
import { StoreManager } from '@localfirst/state'
import { Provider } from 'react-redux'

const storeManager = new StoreManager({
  // Pass your reducers
  proxyReducer,

  // Pass an initial state, just like you would for Redux
  initialState: {
    todoList: [],
    todoMap: {},
    filter: ALL,
  },
})

export const Index = () => {
  // Obtain a Redux store
  const store = storeManager.createStore(discoveryKey)
  return (
    // Pass the store to your app
    <Provider store={store}>
      <App />
    </Provider>
  )
}

๐Ÿก’ More on how to use @localfirst/state in your app

Limitations

This library requires that the entire repository be present on each peer's machine. That means that it is limited to datasets that can fit comfortably within the disk space on a single computer. In 2019, that means something on the order of 1-10 GB.

Further reading

Alternatives

All of these projects are working in similar problem space, in JavaScript. All work in Node.js and the browser unless otherwise noted.

About

A Redux-based state container for local-first software, offering seamless synchronization using Automerge CRDTs. (Formerly known as ๐ŸŸ Cevitxe).

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages