Template app that creates a widget & react iframe.
Code organization:
| dir / path | description |
|---|---|
| ui-src/ | This is where the iframe code lives |
| ui-src/index.html | Main entry point for the iframe code |
| ui-src/tsconfig.json | tsconfig for the iframe code |
| widget-src/ | This is where the widget code lives |
| widget-src/code.tsx | Main entry point for the widget code |
| widget-src/tsconfig.json | tsconfig for the widget code |
| dist/ | Built output goes here |
- The widget code just uses esbuild to bundle widget-src/code.tsx into one file.
- The iframe code uses a tool called vite to bundle everything into a single html file
- Make a copy of this folder
- Update manifest.json, package.json and package-lock.json where it says
WidgetTemplate - Install the required dependencies
npm ci
- "Import widget from manifest"
- Build code
npm run build - Choose your manifest
The quickest way to build your widget during development is by running:
npm run devThis command starts the follow in watch mode:
- typechecking for widget-src & ui-src
- bundling for widget-src & ui-src
- starts a vite dev server that servesr ui-src/index.html at localhost:3000
| script | description |
|---|---|
| npm run build | one-off full build of both the iframe and widget |
| npm run build:production | one-off full production (minified) build of both the iframe and widget |
| npm run build:main | one-off build of the widget code |
| npm run build:ui | one-off build of the iframe code |
| npm run tsc | typecheck both the iframe and widget |
For more information about widgets, please visit the widget documentation at https://www.figma.com/widget-docs.
If you find anything bugs or have any questions, please reach out via https://www.figma.com/widget-docs/get-help/.