Development, Testing, and Publishing
Development workflow, testing strategies, publishing, and troubleshooting.
Development Workflow
Local Development
- Open Figma Desktop
- Plugins -> Development -> Import plugin from manifest
- Select your
manifest.json - Run
npm run watchin terminal - Make changes -> Save -> Plugins -> Development -> Your Plugin
- Use Console (Plugins -> Development -> Show/Hide Console)
Hot Reload (Sort of)
Figma doesn't support true hot reload. Workaround:
// code.ts - During development
figma.showUI(__html__, { width: 400, height: 300 });
// Close and reopen to see changes
// Keyboard shortcut: Cmd/Ctrl + Alt + P (run last plugin)Console Logging
// Main thread - appears in Figma console
console.log('Main thread log');
// UI thread - appears in browser console
// View with: Plugins -> Development -> Show/Hide Console
console.log('UI log');Testing
Manual Testing Checklist
- Plugin loads without errors
- UI displays correctly
- Selection handling works
- Empty selection handled
- Large selection handled
- Error states handled
- Cancel/close works
- Undo works after plugin actions
- Works in both light and dark themes
Automated Testing
// __tests__/utils.test.ts
import { hexToRgb, rgbToHex } from '../src/utils/colors';
describe('hexToRgb', () => {
test('converts hex to RGB', () => {
expect(hexToRgb('#FF0000')).toEqual({ r: 1, g: 0, b: 0 });
expect(hexToRgb('#00FF00')).toEqual({ r: 0, g: 1, b: 0 });
expect(hexToRgb('#0000FF')).toEqual({ r: 0, g: 0, b: 1 });
});
});// package.json
{
"scripts": {
"test": "jest"
},
"devDependencies": {
"jest": "^29.0.0",
"@types/jest": "^29.0.0",
"ts-jest": "^29.0.0"
}
}Mock Figma API
// __mocks__/figma.ts
export const figma = {
currentPage: {
selection: [],
findAll: jest.fn(() => []),
findOne: jest.fn(() => null),
},
createRectangle: jest.fn(() => ({
type: 'RECTANGLE',
x: 0,
y: 0,
resize: jest.fn(),
})),
notify: jest.fn(),
closePlugin: jest.fn(),
ui: {
postMessage: jest.fn(),
onmessage: null,
},
};
// jest.setup.ts
(global as any).figma = figma;Publishing
Prepare for Publishing
- Create cover image (1920x960)
- Create icon (128x128)
- Write description
- Test thoroughly
- Build production bundle
manifest.json for Publishing
{
"name": "My Awesome Plugin",
"id": "1234567890123456789",
"api": "1.0.0",
"main": "dist/code.js",
"ui": "dist/ui.html",
"editorType": ["figma"]
}Publishing Steps
- Go to Figma -> Plugins -> Manage plugins
- Find your development plugin
- Click "Publish"
- Fill in details:
- Name (up to 50 characters)
- Tagline (up to 100 characters)
- Description (markdown supported)
- Cover image
- Categories
- Tags
- Submit for review
Review Guidelines
Figma reviews plugins for:
- Security: No malicious code
- Privacy: Clear data handling
- Quality: Works as described
- Guidelines: Follows community guidelines
Common rejection reasons:
- Plugin crashes or has major bugs
- Missing or misleading description
- Inappropriate content
- Privacy policy issues (if collecting data)
Updating Published Plugin
- Update version in code if tracking
- Build production bundle
- Go to Figma -> Plugins -> Manage plugins
- Click "Edit" on your plugin
- Upload new files
- Update description if needed
- Submit update
Common Issues
"Plugin timed out"
// PROBLEM: Long-running operation
for (let i = 0; i < 10000; i++) {
figma.createRectangle();
}
// SOLUTION: Batch with yields
async function createMany(count: number) {
for (let i = 0; i < count; i += 100) {
for (let j = 0; j < Math.min(100, count - i); j++) {
figma.createRectangle();
}
await new Promise(r => setTimeout(r, 0));
}
}"Cannot read properties of null"
// PROBLEM: Not checking for null
const node = figma.currentPage.selection[0];
node.name = 'New name'; // Crashes if nothing selected
// SOLUTION: Check first
const selection = figma.currentPage.selection;
if (selection.length === 0) {
figma.notify('Select something first');
return;
}
const node = selection[0];"Font not loaded"
// PROBLEM: Modifying text without loading font
const text = figma.createText();
text.characters = 'Hello'; // Error!
// SOLUTION: Load font first
const text = figma.createText();
await figma.loadFontAsync({ family: 'Inter', style: 'Regular' });
text.characters = 'Hello';UI Not Showing
// PROBLEM: Missing __html__
figma.showUI('<html>...</html>'); // Won't work
// SOLUTION: Use __html__ (replaced at build time)
figma.showUI(__html__);
// Or for inline HTML (development only)
figma.showUI(`<html><body>Hello</body></html>`, { width: 200, height: 100 });Network Requests Blocked
// manifest.json - Add network access
{
"networkAccess": {
"allowedDomains": ["api.example.com"],
"reasoning": "Fetch data from our API"
}
}Templates & Starters
Official Templates
# Create React App template
npx create-react-app my-plugin --template figma-plugin
# Figma's official starter
# Download from: https://www.figma.com/plugin-docs/setup/Community Templates
# TypeScript + esbuild
npx degit nicebook/figma-plugin-typescript-template my-plugin
# React + TypeScript
npx degit nicebook/figma-plugin-react-template my-plugin
# Svelte
npx degit nicebook/figma-plugin-svelte-template my-pluginMinimal Starter
mkdir my-plugin && cd my-plugin
npm init -y
npm install --save-dev @figma/plugin-typings typescript esbuildCreate files:
manifest.json(copy from above)src/code.tstsconfig.json(copy from above)esbuild.config.js(copy from above)