Widget Control
The SDK provides three methods to control the feedback widget’s lifecycle: show(), hide(), and destroy().
show()
Mounts the feedback widget to the DOM and displays the trigger button. The widget is lazy-loaded on first call.
await maestrio.show();Behavior
- Lazy loading: The widget code is dynamically imported on the first
show()call, keeping the initial bundle small. - Prerequisite: Throws a
NotIdentifiedErrorifidentify()was not called first. - Idempotent: Calling
show()multiple times does not create duplicate widgets.
Example: show on button click
document.getElementById("feedback-btn").addEventListener("click", () => {
maestrio.show();
});hide()
Closes the widget panel but keeps it mounted in the DOM. The trigger button remains visible.
maestrio.hide();Behavior
- If the widget is not mounted, this is a no-op.
- The widget can be re-opened by the user clicking the trigger button, or by calling
show()again.
destroy()
Completely removes the widget from the DOM and cleans up all event listeners.
maestrio.destroy();Behavior
- After calling
destroy(), you must callshow()again to re-mount the widget. - The widget will be re-created from scratch (lazy-loaded again).
- The identified user is preserved — you don’t need to call
identify()again.
Example: cleanup in a SPA
// React
useEffect(() => {
maestrio.show();
return () => maestrio.destroy();
}, []);// Vue
onMounted(() => maestrio.show());
onUnmounted(() => maestrio.destroy());Lifecycle
identify() → show() → [user interacts] → hide() / destroy()
↑ |
└──────────── show() ←─────────┘identify()— required before any widget interactionshow()— mounts widget (first time) or re-opens ithide()— closes panel, trigger stays visibledestroy()— removes everything from the DOM