Quick start: a real editor in your page

Install @kition/embed, put the kit package (static files: the editor and its WebAssembly engine) on your own CDN, mount the editor on an element and save through your own storage: a working document editor in four steps.

Four steps put a real editor in your page: install the package, put the kit package on your CDN, mount the editor on an element, and save through your own storage. Every kit works this way; below it is Note, one of the two kits whose packages are published today, with Table (the other kits change only the kit and the file). It is free and needs no key.

1. Install

npm i @kition/embed

@kition/embed has no dependencies; a single-user mount runs about 90 KB of it. The SDK bundle carries the same package as a tarball (distribution).

2. Host the kit package on your CDN

The editor itself is not in the npm package. Each kit's editor is a kit package: static files, the editor and its WebAssembly engine (with its fonts), that you put on your own CDN, object storage or any static host. When someone opens a file, the browser downloads the editor and the .wasm from that address, about 22 MB for Note the first time and then from its cache. No Kition server is involved, and Kition does not host kit packages for your product.

The Note kit's package is kition-note-<version>.tgz on kition-note's Releases; it unpacks to note-ui/:

# 1. the Note kit package, from kition-note's release
curl -LO https://github.com/KitionAI/kition-note/releases/download/package-v0.1.0/kition-note-0.1.0.tgz
tar -xzf kition-note-0.1.0.tgz
# → note-ui/: index.html, assets/, engine/ (the .wasm), fonts/

# 2. upload note-ui/ to your CDN, object storage or static host,
#    on an origin that is not your page's, e.g.
#    https://cdn.example.com/kition/note-ui/

# 3. check the engine is served as WebAssembly
curl -sI https://cdn.example.com/kition/note-ui/engine/kition_note_kit_bg.wasm | grep -i content-type
# content-type: application/wasm

Use an origin that is not your page's: the editor runs in a sandboxed frame of that origin, so it cannot reach your page's cookies, storage or session. On that origin:

  • serve .wasm as application/wasm;
  • send a content security policy whose frame-ancestors names your page, and no X-Frame-Options: DENY or SAMEORIGIN;
  • CORS: the frame needs none; if your page reviews agent drafts, let it read model/schema.json;
  • cache the hashed files under assets/ for a year (immutable) and the rest for a short time, so a new version reaches people.

The full list, with the exact policy, is in the embed reference ("Hosting kit packages"); Embed has the same steps.

3. Mount

Point kit.url at the folder on your CDN:

import { KitionEmbed } from '@kition/embed'

const editor = await KitionEmbed.mount(element, {
  kit: {
    id: 'kit.note',
    // static files on your CDN: the editor and its WebAssembly engine
    url: 'https://cdn.example.com/kition/note-ui/',
  },
  file: { id: 'plan-2026', name: 'Plan.md' },
  storage,             // your StorageProvider: read, stamp, write (versioned), create
  identity,            // your IdentityProvider: token, user, users, permissions
})
await editor.ready()

The editor runs sandboxed in a frame from your CDN's origin. identity names the person and what they may do with the file: edit, comment or view.

4. Save to your storage

The editor reads and writes only through your StorageProvider. A write carries the version it read; refuse a stale one with EmbedConflictError, so an edit made elsewhere is never written over:

import { EmbedConflictError } from '@kition/embed'

const storage = {
  read: async (fileId) => {
    const file = files.get(fileId)
    return { bytes: file.bytes.slice(), version: `v${file.version}` }
  },
  stamp: async (fileId) => (files.has(fileId) ? `v${files.get(fileId).version}` : null),
  write: async (fileId, bytes, { expectedVersion }) => {
    const file = files.get(fileId)
    const current = `v${file.version}`
    if (expectedVersion !== null && expectedVersion !== current) throw new EmbedConflictError(fileId, current)
    files.set(fileId, { ...file, bytes: bytes.slice(), version: file.version + 1 })
    return { version: `v${file.version + 1}` }
  },
  create: async (name, bytes) => { /* an export or a copy: keep it, answer { fileId, name, version } */ },
}

Save on your own button, and follow the document:

saveButton.onclick = () => editor.save()
editor.on('changed', () => showUnsaved())
editor.on('saved', () => hideUnsaved())
editor.on('error', (error) => report(error))

Where to go from here

  • Embed: checks, an agent's draft reviewed in the page, your agent in the open editor.
  • Script: edit the open document from code with @kition/script.
  • Co-editing: add collaboration: { server } for real-time editing.
  • URL embedding: no module in your page, a signed iframe URL from @kition/embed-server.
  • Try the editors first in the playground.