Skip to main content

Getting Started


npm install replicache replicache-react

Client Setup#

import {Replicache} from 'replicache';import {useSubscribe} from 'replicache';import {nanoid} from 'nanoid';
const rep = new Replicache({  mutators: {    createTodo: (tx, args) => {      tx.put(`/todo/${}`, args);    },  },});
function MyComponent() {  const todos = useSubscribe(    rep,    tx => tx.scan({prefix: '/todo/'}).toArray(),    [],  );
  const handleClick = () => {    rep.mutate.createTodo({      id: nanoid(),      order: todos.length,      text: 'new todo!',    });  };
  // ...}

Server Setup#

In order to sync, you will need to implement push an pull endpoints on your server.

For detailed information, see the integration guide, or the push/pull reference docs.