Skip to content

API reference > @kontsedal/olas-core > OlasPlugin

OlasPlugin type ​

A plugin: a named setup that runs once for every root the plugin is installed in. The value is a definition, not an instance. Per-root state lives in setup's closure, so one plugin value can be shared by any number of roots, including a HydrationBoundary that rebuilds its root.

ts
const logger = definePlugin({
  name: 'logger',
  setup(host) {
    return {
      onWrite: (e) => console.log(e.query.id, e.source, e.key),
    }
  },
})

createRoot(app, { deps, queries: queryEngine(), plugins: [logger] })

Spec §13.

Signature:

typescript
type OlasPlugin = {
  readonly name: string;
  setup(host: PluginHost): PluginHooks | void;
};

References: PluginHost, PluginHooks

Released under the MIT License.