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.
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 watchThen in Figma desktop :
- Open any design file.
- Go to Plugins > Development > Import plugin from manifest...
- Select the
manifest.jsonin this project. - 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.
- 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 thefigmaAPI (canvas, nodes, selection). It has no DOM. - Messages -
app/plugin/messages-type.ts. The UI and plugin logic talk throughpostMessage. 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.
| 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 |
See CONTRIBUTION.md.