npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

figma-comlink

v0.0.3

Published

Comlink endpoints for communicating between Figma plugin threads

Readme

figma-comlink

Comlink endpoint utilities for Figma plugins

Install

npm i figma-comlink

or

yarn add figma-comlink

Usage

Exposing plugin methods to the UI

Declare your object you want to expose and call Comlink's expose method with an endpoint from figma-comlink:

// plugin.js
import * as Comlink from "comlink";
import { uiEndpoint } from "figma-comlink";

const api = {
  foo() {
    return 'bar';
  }
  // If you want to expose figma's built in methods, make sure to wrap it with a `proxy`
  clientStorage: Comlink.proxy({
    getAsync: figma.clientStorage.getAsync,
    setAsync: figma.clientStorage.setAsync,
  }),
}

Comlink.expose(api, uiEndpoint());

and then use it from the UI thread like so:

// ui.js
import * as Comlink from "comlink";
import { pluginEndpoint } from "figma-comlink";

const plugin = Comlink.wrap(pluginEndpoint());

plugin.foo()
  .then(console.log) //-> "bar"

Exposing UI methods to the plugin

Define your UI methods:

// ui.js
import * as Comlink from "comlink";
import { pluginEndpoint } from "figma-comlink";

const api = {
  notify(msg) {
    // ... your notification implementation
    window.alert(msg)
  }
};

Comlink.expose(api, pluginEndpoint);

add UI endpoint and use your exposed method

// plugin.js
import * as Comlink from "comlink";
import { uiEndpoint } from "figma-comlink";

const ui = Comlink.wrap(uiEndpoint());

ui.notify("Hey ma! I'm sending a notification from plugin thread!")

API

uiEndpoint

() => Comlink.Endpoint

Creates a UI endpoint. This should be used in your plugin thread.

pluginEndpoint

({ targetOrigin, pluginId }?: Options) => Comlink.Endpoint

Options:

  • targetOrigin?: string Origin on which we should listen and send messages to. Defaults to '*'

  • pluginId?: string Your plugin ID

Creates a plugin endpoint. This should be used in your UI thread

If your UI lives on a different origin or you have potentially sensitive data, you should pass pluginId and targetOrigin:

const plugin = Comlink.wrap(
  pluginEndpoint({
    pluginId: "<<your plugin id>>",
    targetOrigin: "https://www.figma.com",
  })
);

See more at Figma's docs here