Extending Kinto.js

Custom database adapters

By default, Kinto.js performs all local persistence operations using IndexedDB; though if you want to create and use you own, that's definitely possible.

Simply create a class extending from Kinto.adapters.BaseAdapter, which rather acts as an interface than anything else here:

class MyAdapter extends Kinto.adapters.BaseAdapter {
  constructor(dbname) {
    super();
    this.dbname = dbname;
  }

  create(record) {
    …
  }

  update(record) {
    …
  }

  …
}

Then create the Kinto object passing a reference to your adapter class:

const kinto = new Kinto({adapter: MyAdapter});

Read the BaseAdapter class source code to figure out what needs to be implemented exactly. IDB and LocalStorage adapters are also worth a read if you need guidance writing your own.