Skip to main content

figwire - bidirectional awaitable IPC communication for figma plugin development


Jakub Hajduk

Hi, I’m an author of an figwire - lightweight typescript friendly library for seamless communication between plugin and UI layers.

https://www.npmjs.com/package/figwire

 

How does it work:

  1. For the work on the plugin side use imports from `figwire/plugin`, and for the work on the ui side use imports from `figwire/ui` 
  2. On the one side you define the methods that will be available on the other side:
    const pluginApi = defineApi({
      greet: (name: string) => `Hello ${name}!`
    });

     

  3. Export the type for these definitions:

    export type PluginAPIDefinition = typeof pluginApi;

     

  4. Provide the type for the client on the other side:
    const pluginApiClient = client<PluginAPIDefinition>();

     

  5. Use the methods using typescript suggestions:

    const greeting = await pluginApiClient.greet('Johnny Jeep');

 

And that’s it.

 

It’s an early release, therefore I am open to suggestions.

Please let me know what you think!

 

0 replies

Be the first to reply!

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings