Skip to main content

JavaScript Installation Instructions

Ditto's JavaScript SDK can run either in the browser, NodeJS, or Electron environments. React Native support is currently under development. For more information about browser support or NodeJS and Electron support click here.

  1. Add the JS package with either npm or yarn.
npm install --save @dittolive/ditto# or with yarnyarn add @dittolive/ditto
  1. Import it like any other NPM package in your source and start using it:
import { init, Ditto } from '@dittolive/ditto'
(async () => {  await init() // you need to call this at least once before using any of the Ditto API  const identity = { type: 'onlinePlayground', appID: 'com.example.ditto' }  const ditto = new Ditto(identity, 'playground')})()