Skip to main content

Initializing Retomus

Before defining machines or contexts, you must first initialize the Retomus engine with optional configuration for global behaviors.

Step 1: Create a Retomus Config

You can customize how Retomus handles values and integration using createRetomusConfig:

import { createRetomusConfig } from 'retomus';

const retomusConfig = createRetomusConfig({
valueCategories: [
/* custom categories */
],
});

Step 2: Create a Retomus Instance

Use the config to initialize the core retomus engine:

import { createRetomus } from 'retomus';

const retomus = createRetomus(retomusConfig);

Once initialized, this instance provides:

  • createMachine()
  • createCtx()
  • createCompositeAction()

Example

const retomus = createRetomus(
createRetomusConfig({
valueCategories: [],
}),
);

You only need to do this once per app.