Skip to content

API Reference

HTML Attributes

AttributeTypeDescription
srcstringURL or path to a .rea or .reast file

Events

All events are CustomEvent instances with typed detail.

rea-loaded

Fired when the story has been parsed and is ready to render.

typescript
interface ReaLoadedDetail {
  title: string;
  partCount: number;
}

rea-choice

Fired when the reader selects a choice.

typescript
interface ReaChoiceDetail {
  label: string;
  index: number;
}

rea-complete

Fired when the story reaches a terminal node (no more content to display).

typescript
interface ReaCompleteDetail {
  storyId?: string;
}

rea-error

Fired when a parse error, load error, or runtime error occurs.

typescript
interface ReaErrorDetail {
  code: string;
  message: string;
}

JavaScript API

After the element is connected to the DOM, you can access these methods and properties:

Properties

PropertyTypeDescription
storyReaDocument | nullThe parsed story document
engineStoryEngine | nullThe running engine instance

Methods

MethodDescription
load(src: string)Load a story from a URL
reset()Reset the story to the beginning

Subpath Exports

The @reast/engine package exposes multiple subpath imports:

ExportDescription
@reast/engineMain barrel — Node-safe (parser, loader, runtime, errors, types)
@reast/engine/parserREA language lexer + parser
@reast/engine/loader.reast archive loader (extraction, decryption, manifest)
@reast/engine/runtimeStoryEngine, expression evaluator, state manager
@reast/engine/player<reast-player> web component (browser-only)
@reast/engine/geoGeo-position utilities
@reast/engine/errorsError classes and codes
@reast/engine/typesTypeScript type definitions