AI Chat Widget
Drop-in AI chat interface with streaming responses, message history, typing indicators, and markdown rendering. Connects to any OpenAI-compatible API.
ReactAI WorkflowsBuilt with Cursor
2.1k
Stars
10.8k
Installs
2
Deps
2
Comments
Install / Copy
npx create-freestack-module ai-chat-widgetCode Preview
index.tsx
"use client";
import { useState, useRef } from "react";
export function ChatWidget({ apiEndpoint, systemPrompt }) {
const [messages, setMessages] = useState([]);
const [input, setInput] = useState("");
const [streaming, setStreaming] = useState(false);
const sendMessage = async () => {
const userMsg = { role: "user", content: input };
setMessages((prev) => [...prev, userMsg]);
setInput("");
setStreaming(true);
const res = await fetch(apiEndpoint, {
method: "POST",
body: JSON.stringify({ messages: [...messages, userMsg], systemPrompt }),
});
const reader = res.body.getReader();
let assistantMsg = "";
while (true) {
const { done, value } = await reader.read();
if (done) break;
assistantMsg += new TextDecoder().decode(value);
setMessages((prev) => [...prev.slice(0, -1), { role: "assistant", content: assistantMsg }]);
}
setStreaming(false);
};
}SA
saasfounder3 days ago
Integrated this into our support page in under an hour. Streaming works perfectly.
DE
designdev1 week ago
The default styling is clean but easy to customize. Works great with Tailwind.
Related Modules
Kanban Board
Drag-and-drop Kanban board with real-time sync via WebSockets. Supports multiple boards, swimlanes, card assignments, and priority labels out of the box.
2.3kReact
Data Table Pro
Full-featured data table with sorting, filtering, pagination, column resizing, and CSV export. Built on TanStack Table with a clean, customizable UI.
1.9kReact
File Uploader
Drag-and-drop file upload component with progress bars, file type validation, and direct S3/R2 integration. Supports multi-file uploads and image previews.
1.4kReact