Lifecycle overview
Constructor
When you instantiate your plugin class (
new MyPlugin()), the base FDO_SDK constructor runs automatically. It registers the plugin instance with PluginRegistry and signals readiness to the host via the communicator.The
new MyPlugin() call at the bottom of the file is required. The FDO host expects the plugin to self-register at module load time.init()
The host sends a The
PLUGIN_INIT message to trigger your init() method. Use this phase to set up handlers, configure storage, and perform any one-time initialization work.PLUGIN_INIT payload may include:content.apiVersion— the host’s expected API version. The SDK validates major-version compatibility againstFDO_SDK.API_VERSIONand throws if they differ.content.capabilities— the set of capabilities the host grants to this plugin instance.
init() fails:
If init() throws, PluginRegistry.callInit() re-throws the error. The host receives a response with an empty capabilities list and an error field. Your plugin will not proceed to the render phase.render()
After a successful What happens when
init(), the host sends a PLUGIN_RENDER message. Your render() method must return a UI string synchronously. The SDK serializes this string via serializeRender() and sends it back to the host, which then mounts it inside a sandboxed iframe.render() fails:
If render() or serializeRender() throws, PluginRegistry.callRenderer() records the error and re-throws. The host receives a fallback error UI and an error field in the render response.renderOnLoad() (optional)
renderOnLoad() returns an optional string that the host executes inside the iframe after it mounts your render output. Use it to set up DOM event listeners, initialize third-party UI libraries, or attach iframe-side logic that must run after the DOM is ready.FDO_SDK) returns '() => {}' — an empty function string — so you only need to override this method when you have on-load work to do.Like
render(), renderOnLoad() must be synchronous. The SDK uses serializeRenderOnLoad() to package the string for host transport. Returning a Promise throws the same async error as render().UI message handlers
After mounting, your plugin UI communicates back to the plugin backend by calling Then call handlers from your UI:What happens when a handler fails:
If a registered handler throws,
window.createBackendReq(handlerName, payload). The host routes these calls as UI_MESSAGE messages to your registered handlers.Register handlers in init() using PluginRegistry.registerHandler:PluginRegistry.callHandler() catches the error, logs it, and returns null. The host receives { error: string } in the UI_MESSAGE response.If the handler name is not registered, callHandler logs a warning and returns null.Message types reference
| Message | When sent | SDK action |
|---|---|---|
PLUGIN_INIT | Host loads the plugin | Calls PluginRegistry.callInit() → your init() |
PLUGIN_RENDER | After successful init | Calls PluginRegistry.callRenderer() → your render() + renderOnLoad() |
UI_MESSAGE | User interacts with the plugin UI | Calls PluginRegistry.callHandler(name, data) → your handler |
Error behavior summary
| Phase | Error behavior |
|---|---|
init() throws | Host receives empty capabilities + error. Plugin does not render. |
render() throws | Host receives fallback error UI + error in render response. |
render() returns a Promise | SDK throws immediately with a clear message before serialization. |
renderOnLoad() returns a Promise | SDK throws immediately with a clear message before serialization. |
| Handler throws | Handler returns null; host receives { error: string }. |
| Handler not found | Handler returns null; warning is logged. |