How to have a widget duplicate itself after a user interaction?

Hi there,

Over the past few days I’ve been playing with APIs to build a FigJam plugin and a FigJam widget that interact to provide the behavior I seek.

What I’d like to do is to make a Widget that creates itself after clicking on a button within the widget itself (similar to the interaction on a sticky note in FigJam).
It seems I need to make a call to figma.importComponentByKeyAsync but for that to work I need to publish my widget first. Is there a way around this?
Or am I taking a completely wrong approach here?

Any help is much appreciated, thanks in advance :smile:

All the best, Marijn

Get the widget id with the useWidgetId() hook, then clone the node with that id.
Check out the code example here:

Thanks a lot @tank666! That does the trick :slight_smile: