Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Framework-free open-source AI chat UI library for websites.
Persona.js is an open-source, framework-free AI chat UI library for websites. Built in vanilla JavaScript, it allows developers to add a streaming, themeable AI chat widget to any website in minutes. It supports SSE streaming, agent loops, tool use, and style isolation via Shadow DOM, with zero framework dependencies.
Install via npm or use a script tag:
npm install @runtypelabs/persona<script src="https://cdn.jsdelivr.net/npm/@runtypelabs/persona@4/dist/install.global.js"></script>Import the stylesheet and init function:
import "@runtypelabs/persona/widget.css";
import { initAgentWidget } from "@runtypelabs/persona";Mount the widget by calling initAgentWidget with a target element and configuration:
initAgentWidget({
target: "#chat",
config: { apiUrl: "https://your-api.com/chat" },
});Choose a layout mode: floating (default), docked, or fullscreen by adjusting the launcher config.
Connect any SSE backend – Persona works with any backend that streams SSE events. Use customFetch and parseSSEEvent to adapt request/event shapes.
document.modelContext and asks user before calling themcustomFetch and parseSSEEventPersona.js is an open-source project released under the MIT License. It is free to use. The team behind Persona also offers Runtype, a hosted service that provides a CLI to quickly set up agents and client tokens.
Q: Does Persona require a specific backend?
A: No. Persona works with any SSE backend. You can adapt request/event shapes using customFetch and parseSSEEvent.
Q: Will Persona break my existing styles? A: No. Persona uses Shadow DOM and prefixed CSS to fully isolate its styles from the host page.
Q: Can I use Persona without npm? A: Yes. You can install it via a script tag from a CDN.
Q: What is WebMCP?
A: WebMCP is a standard that gives the browser a place for page tools via document.modelContext. Persona discovers those tools and asks the user before calling them.
Q: How do I change the layout?
A: Adjust the launcher config in initAgentWidget. Options include floating (default), docked (with side and width), and fullscreen (with fullHeight: true).