use-chrome-ai
v0.1.2
Published
Headless, framework-agnostic primitives for Chrome's built-in AI (Gemini Nano): Prompt, Summarizer, Writer, Rewriter, Proofreader, Translator, Language Detector. Zero dependencies.
Maintainers
Readme
use-chrome-ai
Framework-agnostic primitives for Chrome's built-in AI. Use Gemini Nano in the browser with zero dependencies, no API keys, no server round trip, and no bundled UI.
Live demos: React examples and Vue chat show the same core running through framework adapters.
Install
npm i use-chrome-aiQuick Chat Controller
Use the core package when you are building vanilla JavaScript, another framework adapter, or shared AI logic that should not depend on React or Vue.
import { createChat } from "use-chrome-ai";
const chat = createChat({
system: "You are a concise, friendly assistant.",
});
const status = chat.getSnapshot();
if (status.availability === "downloadable") {
downloadButton.onclick = () => void chat.download();
}
sendButton.onclick = async () => {
for await (const delta of chat.send(input.value)) {
output.textContent += delta;
}
};The core handles availability checks, explicit model downloads, streaming, aborts, context-full errors, and session invalidation when Chrome evicts a model handle.
Packages
For framework apps, start with the adapter:
@use-chrome-ai/reactfor React hooks@use-chrome-ai/vuefor Vue composables
Both adapters re-export this core package, so app code can import hooks/composables and lower-level controllers from one place.
