0.0.2

useConfig

Get, set, and deep merge widget configuration at runtime with getConfig, setConfig, and mergeConfig.

The config store is available on every ScenaInstance at instance.config. It provides reactive access to the current configuration and methods to update it without remounting.

const instance = await scena.mount({
  video: { src: '/video.mp4' },
  size: ComponentSize.MD,
});

const config = instance.config;

Properties

PropertyTypeDescription
currentScenaConfigCurrent resolved config snapshot

Methods

MethodSignatureDescription
getConfig() => ScenaConfigReturns the current config object
setConfig(value: ScenaConfig) => voidReplaces the entire config
mergeConfig(partial: Partial<ScenaConfig>) => voidDeep merges partial config into current

Reading config

const config = instance.config.getConfig();

console.log(config.size);
console.log(config.video.src);

The current property returns the same snapshot reactively:

console.log(instance.config.current.shape);

Replacing config

Replaces the entire config. All properties must be provided:

instance.config.setConfig({
  video: { src: '/other.mp4' },
  size: ComponentSize.LG,
  shape: ComponentShape.PORTRAIT,
});

Merging config

Deep merges a partial update into the existing config. Unmentioned properties stay unchanged:

instance.config.mergeConfig({
  size: ComponentSize.LG,
  ctaButton: { text: 'New label' },
});

This is the preferred way to update individual properties at runtime.