← All articles
GuideBy Oven AI Team · September 23, 2026

How to Build Your First Tool With the Figma Plugin API in 2026

Photo: AI-generated via gpt-image-2

Figma plugins are like superpowers for your design workflow. They are small add-ons that extend the functionality of the core interface, allowing you to automate repetitive tasks, sync with external data, and customize how you work.

Whether you are an engineer or a designer writing your first plugin, building for Figma is highly accessible. You don't need to learn a proprietary language; instead, you can leverage standard web technologies because plugins are powered by web technologies like HTML and JavaScript.

Here is a step-by-step technical guide to building your first plugin, moving past high-level concepts into actual implementation.

1. How to set up your manifest.json and development environment

To begin building, you need to configure your local development environment. Create a new project folder on your computer. The most critical component in this folder is your manifest.json file.

This file acts as the configuration blueprint for your plugin, telling Figma the plugin's name, its ID, and where to find your code. A standard manifest points to two distinct files: your main sandbox code (e.g., code.js) and your user interface code (e.g., ui.html). Once your manifest.json is created, you can load it directly into Figma's desktop app via the "Plugins > Development > Import plugin from manifest" menu to test your code locally on the canvas.

2. Figma's Architecture and Using postMessage

Figma plugins operate on a strict two-part architecture for security and performance:

  1. The Sandbox: A secure JavaScript environment where the figma global object lives. This has read and write access to the Figma file.
  2. The UI iframe: A browser-based HTML environment that renders your user interface.

Because these two environments are isolated, they cannot share variables directly. Here is how to use postMessage to communicate between the HTML interface and the sandbox code:

When a user interacts with your ui.html (like clicking a button), you trigger a parent.postMessage event to send a data payload to the sandbox. In your code.js, you listen for this message using figma.ui.onmessage. This API allows two applications to talk to each other—your UI sends the request, and your sandbox code executes the necessary changes to the document.

3. Tips for integrating modern web frameworks (like Next.js) for the plugin's UI

While you can build a plugin with basic HTML and CSS, complex tools benefit from a component-based architecture. Here are a few tips for integrating modern web frameworks (like Next.js or React) for the plugin's UI:

  • Bundle to a Single File: Figma requires your UI to be packaged into a single HTML file. If you use React or Next.js, you must configure your bundler (like Webpack or Vite) to inline all CSS and JavaScript into one index.html output.
  • Use Static Exports: If you are using Next.js, utilize the static export feature (output: 'export' in your config). Figma plugins do not have a Node.js backend server running the UI, meaning server-side rendering (SSR) will not work inside the iframe.
  • Leverage Tailwind CSS: Modern frameworks pair perfectly with utility-first CSS like Tailwind, allowing you to rapidly style your plugin UI to match Figma's native aesthetic without maintaining massive stylesheets.

4. A practical example: Inserting an Oven AI-generated 3D icon PNG

Let's look at a practical example of inserting an external asset (like an Oven AI-generated 3D icon PNG) directly into a Figma file. This is perfect for teams looking to bring high-quality, framework-ready 3D assets straight onto the canvas.

Because working with fonts and images takes time to process, Figma encourages plugin developers to utilize the asynchronous methods provided by the Plugin API.

In your HTML UI, after a user generates or selects their Oven AI 3D icon, your UI sends the image data (as a Uint8Array) to the sandbox via postMessage. Inside your code.js, you handle the asynchronous creation like this:

figma.ui.onmessage = async (msg) => {
  if (msg.type === 'insert-oven-icon') {
    // 1. Create an image from the Oven AI 3D icon bytes asynchronously
    const image = figma.createImage(msg.imageBytes);
    
    // 2. Generate a new rectangle on the canvas
    const rect = figma.createRectangle();
    rect.resize(200, 200);
    rect.name = "Oven AI 3D Icon";
    
    // 3. Apply the image as a fill to the rectangle
    rect.fills = [{ type: 'IMAGE', imageHash: image.hash, scaleMode: 'FILL' }];
    
    // 4. Append to the canvas and focus the viewport
    figma.currentPage.appendChild(rect);
    figma.viewport.scrollAndZoomIntoView([rect]);
  }
};

This instantly places your Oven AI asset right into the design, ready for production.

5. Speeding Up Plugin Development

As you build more complex features, you don't have to write all your node-generation code entirely from scratch.

The Figma to Plugin API tool can dramatically accelerate your workflow. It converts supported nodes like frames, instances, text, rectangles, ellipses, vectors, lines, polygons, and stars into code that you can copy and reuse. This is highly recommended for understanding how designs map to the Plugin API, and generating a solid starting point instead of rebuilding UI structures by hand.

Powered by Oven AI

Try Oven AI

Pay-as-you-bake pricing (no subscription bloat)

Visit Oven AI →
Keep reading