- React + Vite +
vite-plugin-singlefile— Build widgets as React SPAs bundled into one HTML file (TypeScript reference). - Self-contained HTML — Write standalone HTML files with inline CSS and JS. No build step needed (Python reference).
1
Build the ChatGPT widget bridge
The widget bridge wraps the
window.openai API that ChatGPT provides inside widget iframes. The TypeScript example creates a shared module; the Python example calls window.openai directly inline.2
Build the widgets
This section applies to the TypeScript/React implementation only. If you are writing self-contained HTML files directly, as the Python reference implementation does, skip to Integrate Gr4vy Embed.
src/widgets/<widget-name>/App.tsx
3
Configure the widget build process
Compile widgets into self-contained HTML files using Vite and Create Run the build:This produces
vite-plugin-singlefile. The config accepts a WIDGET environment variable so the same file builds every widget:vite.config.ts
scripts/build-widgets.ts to build each widget and rename the output:scripts/build-widgets.ts
product-catalog.html, shopping-cart.html, and checkout.html in dist/widgets/, each fully self-contained.Continue to Integrate Gr4vy Embed.