Skip to main content

Plugins

Plugin Setup

Set up your development environment for building Figma plugins with TypeScript and modern tooling.

This guide covers project configuration, the manifest file, bundling, and publishing your plugin.

Project Setup

1
Initialize the project
2
Create a new directory and initialize with npm:
3
mkdir figma-plugin && cd figma-plugin
npm init -y
npm install -D typescript @figma/plugin-typings
4
Configure TypeScript
5
Create tsconfig.json:
6
{
  "compilerOptions": {
    "target": "ES2020",
    "module": "ESNext",
    "moduleResolution": "bundler",
    "strict": true,
    "typeRoots": ["./node_modules/@figma"]
  },
  "include": ["code.ts"]
}
7
Create the manifest
8
Every plugin needs a manifest.json:
9
manifest.json
{
  "name": "My Plugin",
  "id": "1234567890",
  "api": "1.0.0",
  "main": "code.js",
  "ui": "ui.html",
  "editorType": ["figma"],
  "capabilities": [],
  "permissions": ["currentuser"]
}
manifest.json
{
  "name": "My Plugin",
  "id": "1234567890",
  "api": "1.0.0",
  "main": "code.js",
  "editorType": ["figma"]
}
10
Write your plugin code
11
Create code.ts with your plugin logic:
12
// Access the current selection
const selection = figma.currentPage.selection;

if (selection.length === 0) {
  figma.notify("Please select at least one layer");
  figma.closePlugin();
} else {
  for (const node of selection) {
    if ("fills" in node) {
      node.fills = [{ type: "SOLID", color: { r: 0.63, g: 0.35, b: 1 } }];
    }
  }
  figma.notify(`Updated ${selection.length} layers`);
  figma.closePlugin();
}
13
Build and run
14
Compile TypeScript and load the plugin in Figma:
15
npx tsc
16
In Figma: Plugins > Development > Import plugin from manifest and select your manifest.json.

Manifest Reference

FieldTypeDescription
namestringDisplay name in the plugin menu
idstringUnique plugin ID (assigned by Figma)
apistringPlugin API version
mainstringPath to compiled main thread code
uistringPath to UI HTML file (optional)
editorTypestring[]"figma", "figjam", or "dev"
capabilitiesstring[]Special capabilities like "codegen"
permissionsstring[]Required permissions

The id field must match the ID assigned by Figma when you create the plugin. Using the wrong ID will prevent your plugin from loading.

Bundling with esbuild

For production plugins, use a bundler to handle imports and optimize output:

npm install -D esbuild
import { build } from "esbuild";

build({
  entryPoints: ["code.ts"],
  bundle: true,
  outfile: "code.js",
  target: "es2020",
  format: "esm",
}).catch(() => process.exit(1));

Add a "build": "node build.mjs" script to your package.json for quick builds during development.