Skip to content
Forms, switch product

Dependencies

Some widgets rely on third-party libraries that GolemUI deliberately doesn’t bundle — typically because the choice of library is opinionated. The Markdown widget needs a markdown parser, the File Upload widgets need an upload transport, and you might want to add others. Dependencies are how you supply those helpers to the engine.

A dependency is a key/value pair in a Dependencies object. The key identifies what kind of helper it is (the widgets know which key to read); the value is the helper implementation.

import type { Dependencies, SanitizedHtml } from '@golemui/gui-shared';
const dependencies: Dependencies = {
markdown: {
parse: (md: string) => snarkdown(md) as SanitizedHtml,
},
};

Each widget that uses a dependency reads it at render time. If the widget needs a dependency you haven’t provided, it renders gracefully: the Markdown widget shows the editor but leaves the preview blank, and the File Upload widgets render a disabled box with an inline “not configured” message.

In the Programmatic API, dependencies go inside formConfig.dependencies.

import snarkdown from 'snarkdown';
import { gui, type SanitizedHtml } from '@golemui/gui-shared';
import { GuiForm } from '@golemui/gui-react';
const config = {
formDef: [gui.inputs.markdown('content')],
formConfig: {
dependencies: {
markdown: { parse: (md: string) => snarkdown(md) as SanitizedHtml },
},
},
};
export function MyForm() {
return <GuiForm config={config} />;
}

In the JSON path, dependencies go into the dependencies property in the config object.

{
"form": [{ "kind": "input", "type": "markdown", "path": "content" }]
}
import type { SanitizedHtml } from '@golemui/gui-shared';
import snarkdown from 'snarkdown';
import { GuiForm } from '@golemui/gui-react';
import formDef from './my-form.json';
const config = {
formDef,
dependencies: {
markdown: { parse: (md: string) => snarkdown(md) as SanitizedHtml },
},
};
export function MyForm() {
return <GuiForm config={config} />;
}
KeyUsed byShape
markdownMarkdown, Markdown Text{ parse: (md: string) => SanitizedHtml }
uploadServiceFile Upload, Multi File Upload{ upload(file, ctx) => Promise<unknown>; remove?(item) => Promise<void> }