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
manifest.json
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
| Field | Type | Description |
|---|---|---|
name | string | Display name in the plugin menu |
id | string | Unique plugin ID (assigned by Figma) |
api | string | Plugin API version |
main | string | Path to compiled main thread code |
ui | string | Path to UI HTML file (optional) |
editorType | string[] | "figma", "figjam", or "dev" |
capabilities | string[] | Special capabilities like "codegen" |
permissions | string[] | Required permissions |
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));