Skip to content
Skip to content
Web playback

Chorono JavaScript runtime

The published @chorono/runtime package provides a canvas adapter and player for JavaScript and TypeScript applications. The examples below use version 0.1.0 and a reviewed Chorono runtime export.

Install#

npm install @chorono/runtime@0.1.0

For direct browser scripts or an archive, use SDK downloads. The package includes TypeScript declarations.

Download the published runtime#

Version 0.1.0 is available as an npm package and a package archive. For browser hosting, use the versioned ES module or browser-global script.

This JavaScript animation player renders authored Chorono scenes to a canvas. It does not animate arbitrary HTML elements. The separate WebAssembly SDK and Web Component are coming soon; they are not required for the examples on this page.

Load and render a scene#

Download the title-card runtime JSON and serve it as /animation.runtime.json in your application. Add a canvas to the page:

<canvas id="animation" aria-label="Chorono title animation"></canvas>

Run this module after the canvas exists:

import { ChronoPlayer, CanvasRenderAdapter } from '@chorono/runtime'

const canvas = document.querySelector('#animation')
const context = canvas.getContext('2d')
if (!context) throw new Error('Canvas 2D is unavailable')

const response = await fetch('/animation.runtime.json')
if (!response.ok) throw new Error(`Scene request failed: ${response.status}`)
const exported = await response.json()
if (exported.warnings?.length) console.warn(exported.warnings)

canvas.width = exported.runtime.composition.width
canvas.height = exported.runtime.composition.height
const player = new ChronoPlayer(
  exported.runtime,
  new CanvasRenderAdapter(context),
  { loop: true }
)
player.seek(0)
// Call player.play() from your application's Play control.

Pass exported.runtime, not the entire export wrapper. Keep the editor source JSON separately. These examples use a scene without external media; image and video assets require host-side loading and the player's assets option.

Control playback#

MethodPurpose
player.play()Start the player's animation clock
player.pause()Pause playback
player.stop()Stop and reset playback
player.seek(1500)Seek to 1,500 milliseconds
player.setParam('name', value)Override a declared scene parameter
player.dispatch('event', machineId)Dispatch an event to a configured state machine
player.destroy()Stop the clock and remove player listeners

Use the parameter and event names defined by your scene. See State machines for the authoring side.

Own the lifecycle#

Call destroy() when removing or replacing the player. Cancel pending fetches if the host view closes before loading finishes. Remove any event listeners your own application installed.

The runtime also exposes tick(timeMs) for a host-driven clock. Supply absolute playback time in milliseconds; do not run an independent requestAnimationFrame loop alongside player.play().

Offer play/pause controls and respect the visitor's reduced-motion preference. The React and Vue guides show lifecycle cleanup with playback started by the visitor.

A good place to start
Getting started / Chorono documentationChorono documentationLearn Chorono with editable animation examples. Install the editor, edit keyframes, build loops and connect Claude Code or Codex through MCP. Cre…Getting started / Install ChoronoInstall ChoronoSet up the free, open-source animation editor on your computer and start a local browser session. This guide installs the browser editor, its loc…Getting started / Create your first editable animationCreate your first editable animationOpen an editable Chorono example, change its text and colors, inspect the timeline, then save and reopen your first 2D animation. Start with a re…Workspace / Chorono editor workspaceChorono editor workspaceFind the canvas, layers, properties, timeline and resource tools in the Chorono editor. Choose a guide for each part of your animation workflow.…Workspace / Canvas and drawing toolsCanvas and drawing toolsNavigate the canvas, draw shapes and splines, use snapping and edit motion keys in Chorono. Use the canvas to arrange the objects in your composi…Workspace / Choose a drawing or transform toolChoose a drawing or transform toolUse Select, Pan, Pen, Move, Rotate, Scale and Anchor tools without losing track of the active editing mode. Choose the tool that matches the edit…Workspace / Select exactly the objects you needSelect exactly the objects you needUse box, lasso, circle, paint and rule-based selection to work with several animation layers. When several objects overlap, clicking each one can…Workspace / Align objects with guides and snappingAlign objects with guides and snappingSet grid, object, point, guide, pixel, angle and scale snapping for precise placement in Chorono. Snapping helps a dragged object settle on an ex…Workspace / Edit Bézier points and spline curvesEdit Bézier points and spline curvesDraw editable paths, adjust points and handles, and extend or close a spline in Chorono. A curve is easier to control when you can see the points…Workspace / Edit animation positions on the canvasEdit animation positions on the canvasUse Motion Keys to adjust position keys, draw a movement and control how the path is timed. Motion Keys bring position editing onto the canvas. T…Workspace / Layers and scene hierarchyLayers and scene hierarchySelect, name, group and organize scene objects in Chorono using the Layers panel and Scene Explorer. A layer is an editable object in your Choron…Workspace / Draw and edit basic shapesDraw and edit basic shapesCreate rectangles, circles, polygons and procedural shapes, then adjust their geometry in Properties. Basic shapes are a useful starting point fo…
Explore the docs