



We've got you covered in all your real-time collaboration use cases.
import Cyxth from '@cyxth/core';
import Colab from '@cyxth/colab';
const APP_URL = "my-app.apps.cyxth.com";
const USER_TOKEN = "token_from_backend";
const cyxth = await new Cyxth("YOUR_APP_URL", [Colab])
.connect(USER_TOKEN);
const colab = await cyxth.colab();
const state = await colab.createOrJoin("our-shared-doc");
let doc = state.changeContext().text("doc");
doc.handlers = {
insert(index, text, ctx) {
console.log(ctx.userId);
// update doc in ui
}
// ... more handlers
}
const edit = (index: number, value: string, delCount: number) => {
doc.replace(index value, delCount);
}
// ...