This starter is based on figma ai template. Added more libs and linters to make DX better.
Choosing a technology stack is a very subjective matter, if you happen to like using Vite
, React
,Tailwind
, TS
and shadcn ui
and more to build Figma plugins
, then give it a try.
Clone this repo or create a repo based on this starter on Github
yarn
yarn dev
We prefer Yarn
as package manager, If you want to use pnpm
or npm
, feel free to use
In this example we will be publishing the Next.js app to Vercel. You can also publish to any other hosting provider that supports Next.js.
OPENAI_API_KEY
to your OpenAI API key.
siteURL
section of your package.json
file to point to the deployed URL. It will look something like https://your-site-here.vercel.app/
"config": {
"siteURL": "https://your-site-here.vercel.app/"
}
npm run build
to create the production build of your plugin that points to your deployed URL.This template includes a figmaAPI
helper at @/lib/figmaAPI
that lets you run plugin code from inside of the iframe. This is
useful for avoiding the iframe <-> plugin postMessage API and reduces the amount of code you need to write.
Example:
import { figmaAPI } from "@/lib/figmaAPI";
const nodeId = "0:2";
const result = await figmaAPI.run(
(figma, { nodeId }) => {
return figma.getNodeById(nodeId)?.name;
},
// Any variable you want to pass to the function must be passed as a parameter.
{ nodeId },
);
console.log(result); // "Page 1"
A few things to note about this helper: