Skip to content

Latest commit

 

History

History
44 lines (31 loc) · 872 Bytes

rs.js.index.md

File metadata and controls

44 lines (31 loc) · 872 Bytes

remoteStorage.js

At a glance

Setup

const rs = new RemoteStorage();
rs.access.claim('todos', 'rw');
rs.caching.enable();

const client = rs.scope('/todos/');

Write an object

// Declare an object type to validate if you want (JSON Schema)
client.declareType('todo-item', {});

// Write `{"id":"alfa","done":false}` to /todos/alfa.json
await client.storeObject('todo-item', 'alfa.json', {
  id: 'alfa',
  done: false,
});

Get objects

const specificItem = await client.getObject('alpha.json');
const allTodoItems = await client.getAll();

Add the Connect Widget UI component

Use our drop-in UI widget for connecting remote storage accounts.

const widget = new Widget(rs);
widget.attach();

Protocol details