Quick Start

Let’s start using Yorkie with JS SDK and Agent.

Installation

Install Yorkie JS SDK using npm:

$ npm install yorkie-js-sdk

or just include the following code in the <head> tag of your HTML:

<!-- include yorkie js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/yorkie-js-sdk/0.2.0/yorkie-js-sdk.js"></script>

NOTE: If you want to test Yorkie quickly, You can start Envoy and Yorkie with docker-compose. To start them, downloads manifests files from docker folder, then type docker-compose up --build -d in the folder.
For more details please refer to Agent for Web

How to use

First, create client with RPCAddr then activate it.

const client = yorkie.createClient('localhost:8080');
await client.activate();

Then create a document with a collection name and key of document then attach it into the client.

const doc = yorkie.createDocument('my-docs', 'doc-1');
await client.attach(doc);

This automatically synchronizes all changes to the document attached to the client with the remote peers.

Now let’s make a change on the document:

doc.update((root) => {
  root['key'] = 'value'; // {"key":"value"}
});

The changes are applied immediately locally and propagated to other peers that have attached the document.

Next, let’s take a look at the JS SDK.

Edit this page