You can integrate the Ditto SDK with your web and Node.js projects developed using JavaScript and TypeScript languages.
@dittolive/ditto
package into your project:
appID
placeholder value with the app ID that identifies
your app in Ditto.
token
placeholder value with your playground token that
Ditto Server uses to verify your digital identity before issuing your
playground certificate.
Ditto
instance in the top-most scope of your app. Otherwise, it may be inadvertently garbage collected and no longer accessible throughout the lifecycle of your app.registerSubscription()
in the ditto.sync
namespace to add a sync subscription:
registerObserver()
method on ditto.store
. The passed in callback closure is invoked by Ditto everytime it registers new changes to documents matching the query.
await init()
. By default, the SDK will fetch the asset from Ditto’s CDN.
Alternatively, you can host the binary on another CDN or web server and
configure Ditto to retrieve it from there. You will find the file in the NPM
package at web/ditto.wasm
. Make it available on a web server and provide its
URL when calling init()
:
application/wasm
) and CORS headers.
Please consider your application’s loading UI while downloading the assets as it
may take a few seconds to download and initialize the WebAssembly binary.
It is strongly recommended to serve assets using a web server or CDN that
supports compression. This will significantly reduce the download size of
assets and thereby the loading time of your application.
yao-pkg
yao-pkg
requires adding aditional metadata in order to reduce the size of your executable. To configure your package.json
to include only the binaries for your target platform:
ignore
patterns based on your target platform:
For Windows:
ditto.darwin*.node
and ditto.linux-*.node
ditto.win*.node
ditto.win*.node
and ditto.linux-*.node
ditto.darwin*.node
ditto.win*.node
and ditto.darwin*.node
ditto.linux-*.node