The <generate-html> Web Component is a LLM-powered custom element that generates and renders interactive HTML or SVG images on the fly using Google Gemini or Chrome's built-in AI.
It uses a double iframe architecture to reduce the ability of any generated code to access your API keys or host page data. The outer iframe exposes a limited API to the host page it mediates all communication with the inner iframe.
Both iframes are sandboxed and both iframes are created via blob URLs so their origin's are null. This means that the inner iframe cannot access the host page or any of the host page or the outer iframe. The outer iframe can't directly access the DOM of the inner iframe other than changing the href source.
If I was to summarise the features of this component I would say it supports:
- AI-Generated Content: Turns text prompts into interactive web apps (calculators, games) or SVG images.
- Sandbox: Uses a "Double iframe" architecture to ensure generated code cannot access your API keys or host page data.
- Multi-Provider: Supports Google Gemini (via API Key) and Chrome Built-in AI (experimental
window.LargeLanguageModel). - Vanilla JS: Zero framework dependencies. Built with standard Web Components.
Usage
You can install the component directly via npm:
npm install @paulkinlan/generate-html
Then, import the component script and use the tag in your HTML:
<script type="module" src="/src/generate-html.js"></script>
<generate-html
prompt="Create a snake game"
api-key="YOUR_GEMINI_API_KEY"
model="gemini-2.5-flash-latest"
provider="gemini"
type="html"
></generate-html>
The demo can be accessed here: https://generate-html-element.paulkinlan-ea.deno.net/
For more details, check out the GitHub repository.
I lead the Chrome Developer Relations team at Google.
We want people to have the best experience possible on the web without having to install a native app or produce content in a walled garden.
Our team tries to make it easier for developers to build on the web by supporting every Chrome release, creating great content to support developers on web.dev, contributing to MDN, helping to improve browser compatibility, and some of the best developer tools like Lighthouse, Workbox, Squoosh to name just a few.
I love to learn about what you are building, and how I can help with Chrome or Web development in general, so if you want to chat with me directly, please feel free to book a consultation.
I'm trialing a newsletter, you can subscribe below (thank you!)




