Skip to content

About

A minimal starter for building Figma plugins with React 19, Tailwind CSS v4, TypeScript and Rsbuild.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Figma Plugin React Template

badge badge

A minimal starter for building Figma plugins with React 19, Tailwind CSS v4, TypeScript and Rsbuild.

Figma requires the plugin UI to be a single HTML file. This template handles that for you: the React app is bundled into one self-contained dist/ui.html, and the plugin backend is built to dist/code.js. You write normal React, and it just works inside Figma.

Getting started

Requirements : the Figma desktop app and a package manager (Bun by default).

// Fork this repository
gh repo fork karticme/figma-plugin-react-template --clone
cd figma-plugin-react-template

// run repository
bun install
bun run watch

Then in Figma desktop :

  1. Open any design file.
  2. Go to Plugins > Development > Import plugin from manifest...
  3. Select the manifest.json in this project.
  4. Run it from Plugins > Development.

With watch running, re-run the plugin in Figma to see your changes.

Note

Bun is not required. To use npm, pnpm or yarn instead, delete bun.lock, remove the packageManager field from package.json, and change bunx to npx in the format script. Then install and run as usual, for example npm install and npm run watch.

Where to write code

  • UI - app/ui/App.tsx. This is your React app, rendered in the plugin window. Style it with Tailwind classes.
  • Plugin logic - app/plugin/code.ts. This runs in Figma's sandbox and has access to the figma API (canvas, nodes, selection). It has no DOM.
  • Messages - app/plugin/messages-type.ts. The UI and plugin logic talk through postMessage. Define each message type here so both sides stay typed.

A round trip looks like this :

// UI -> plugin (App.tsx)
parent.postMessage({ pluginMessage: { type: "ui:add-svg" } }, "*");

// plugin handles it, then replies (code.ts)
figma.ui.onmessage = (msg) => {
  if (msg.type === "ui:add-svg") {
    // use the figma API
    figma.ui.postMessage({ type: "plugin:svg-created" });
  }
};

// UI listens for the reply (App.tsx)
window.addEventListener("message", (e) => {
  const msg = e.data.pluginMessage;
});

Tip

Before publishing, update name and id in manifest.json, and adjust the window size in figma.showUI(...) inside code.ts. If your plugin makes network requests, add the domains to networkAccess.allowedDomains.

Scripts

Command Description
bun run watch Build and rebuild on file changes
bun run build Production build to dist/
bun run type-check Run TypeScript without emitting
bun run format Format the codebase with Prettier

Contributing

See CONTRIBUTION.md.

License

MIT

About

A minimal starter for building Figma plugins with React 19, Tailwind CSS v4, TypeScript and Rsbuild.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Sponsor this project

Contributors

Languages