This project template helps you get started developing a Figma plugin using Svelte and TypeScript with Vite (and Tailwind CSS).
[!NOTE] To future-proof this template I've used Svelte 5, which is perfectly usable, but not yet officially released.
types.d.ts
)For optimal experience make sure you have the svelte extension Svelte.
public/manifest.json: That's the plugin manifest file. You should change the name
there, rest can be left as is.
src/: Contains the source code for the project.
lib/: Contains the files you might want to reuse across the plugin ui and logic.
index.ts
: Contains an example of a function that can be used in both the UI and logic.plugin_logic/: Contains the logic for the Figma plugin.
Thats where you can interact with the figma
API.
plugin_ui/: Contains the UI components for the Figma plugin.
Plugin.svelte
: UI entrypoint component for the Figma plugin.app.css
Global CSS for the application.
types.d.ts: TypeScript declaration file.
Other files are for configuration - you shouldn't need to touch them.
I personally recommend using Bun, bun you can also just use
(p)npm
. [^1]
[^1]: If you use raw npm
, use npm run <script>
instead of bun <script>
.
bun install
According to the docs each plugin needs to have a unique id
in the manifest.json
.
You can add one by running:
bun run gen:uuid
This will generate a random UUID and add it to the manifest.json
.
If you want to first prototype only the UI, you can run the following command:
bun dev
Now you can open the browser at http://localhost:5173
to see the UI.
I recommend using responsive mode to simulate the plugins window size.
After you run
bun run build
you'll get a dist/
folder, that contains the compiled plugin code.
Now in Figma desktop, you can add your plugin by going to Plugins
-> Development
-> Import plugin from manifest...
and selecting the dist/manifest.json
file.
Of course, it would be nice if the plugin could reload automatically when you save changes. You can achieve that by opening two terminals and running:
bun dev:ui
This watches for changes in the UI code and rebuilds it.
bun dev:plugin
This watches for changes in the plugin logic code and rebuilds it.
The plugin logic and UI are two different independent parts. We put them in one project for ease of development and code sharing, but ultimately they need to be compiled separately.