DEV Community


How to develop Figma plugin with React + TS

seya profile image kazuya ・2 min read


git clone <your project name>
yarn or npm install
yarn webpack:watch  or  npm run webpack:watch 

Developing Figma plugin is exciting, but when it comes to develop one with some stateful UI, it's a pain to develop in imperative way.

Thus I created a boilerplate to develop with React and here I introduce it.

The content of boilerplate is as follows.

How to render Figma plugin UI with React

There is nothing special, you just have to do ReactDOM.render to ui.html which is specified from manifest.json.

<div id="app"></div>
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { App } from './App';

ReactDOM.render(<App />, document.getElementById('app'));

Sample Code

I paste a sample code of plugin made with React below.

My plugin is to enable incremental search for components and create an instance from it.(actually Figma itself has this feature but I thought it would be nice when keyboard shortcut functionality is added to plugin)

It works as the following gif(sorry my tweet is in Japanese)

Before you start building your plugin, I recommend you to read How Plugins Run document.

You have to beware that main thread which can reference Figma object is different from plugin UI thread.

So you need to use message object to pass data between the threads, my sample code has codes for both directions, so please refer to it.

import { subscribeOnMessages } from 'react-figma';


const componentNodes = figma.root.findAll((node) => node.type === 'COMPONENT');
const conmponentsData = => ({

figma.ui.onmessage = (message) => {

  if (message.type === 'create-instance') {
    const component = figma.root.findOne(
      (node) => ===
    ) as ComponentNode;
import * as React from 'react';

type ComponentItemType = {
  id: string;
  name: string;

export const App = () => {
  const [query, setQuery] = React.useState('');
  const [components, setComponents] = React.useState<ComponentItemType[]>([]);

  React.useEffect(() => {
    onmessage = (event) => {
      setComponents( as ComponentItemType[]);
  }, []);

  const create = (id: string) => {
    parent.postMessage({ pluginMessage: { type: 'create-instance', id } }, '*');

  return (
      <input value={query} onChange={(e) => setQuery(} />
      <div style={{ display: 'flex', flexDirection: 'column' }}>
          .filter((component) => {
            if (query.length === 0) {
              return true;
          .map((component) => (
            <button onClick={() => create(}>

Discussion (0)

Editor guide