
A Chrome Extension that brings on-device AI to your browser using Gemini Nano
NanoChat leverages Chrome's built-in Gemini Nano model to provide AI assistance directly in your browser - no API keys, no cloud processing, everything runs locally on your device. With tab context awareness, NanoChat can understand and reference the content of your active page to provide more relevant responses.
- 100% On-device AI - Uses Chrome's built-in AI capabilities through Gemini Nano
- Tab Context Awareness - Automatically extracts and uses content from your active tab
- Chat History - Easily access and continue previous conversations
- Temperature Control - Adjust the creativity of AI responses
- Dark/Light Mode - Toggle between themes for comfortable viewing
- Persistent Storage - Chat history is saved between browser sessions
- Helpful Guidance - Clear setup instructions if Chrome AI isn't available
NanoChat uses Chrome's experimental Gemini Nano API (available through an Origin Trial) to run AI inference directly on your device.
-
AI Session Management
// Create a new session with tab context and conversation history aiSessionRef.current = await chrome.aiOriginTrial.languageModel.create({ temperature: tempValue, topK: 40, initialPrompts: initialPrompts, })
-
Tab Context Extraction
// Executes a script in the active tab to extract content const result = await chrome.scripting.executeScript({ target: { tabId: tab.id }, func: getPageContent, })
-
Session Safety During Tab Changes
// Don't destroy active sessions during tab changes const resetAISession = useCallback(() => { if (aiSessionRef.current) { if (sessionActive) { setPendingTabContextUpdate(true) return } aiSessionRef.current.destroy() aiSessionRef.current = null } }, [sessionActive])
-
Dynamic Context Updates
// Update context when tabs change chrome.tabs.onActivated.addListener((activeInfo) => { if (useTabContext) { fetchTabContext() } })
- Chrome version 127 or newer
- Enabled Chrome flags for AI features
-
Clone the repository
git clone https://github.com/abpai/nanochat.git cd nanochat
-
Install dependencies
npm install
-
Build the extension
npm run build
-
Load in Chrome
- Open Chrome and go to
chrome://extensions
- Enable "Developer mode" in the top-right corner
- Click "Load unpacked" and select the
dist_chrome
folder
- Open Chrome and go to
-
Enable Chrome AI Features
- Visit
chrome://flags/#prompt-api-for-gemini-nano
and enable it - Visit
chrome://flags/#optimization-guide-on-device-model
and enable it - Restart Chrome
- Visit
chrome://components
and update "Optimization Guide On Device Model"
- Visit
- Click the NanoChat extension icon in your toolbar or open the side panel
- Type your question in the input field
- Toggle the "eye" icon to include/exclude page context
- Adjust temperature settings for more creative or precise responses
- View and continue previous conversations using the history button
- Built using vite-web-extension template
- Inspired by the Gemini On-Device Sample from Google Chrome Extensions Samples
NanoChat processes all data locally on your device. No queries, page content, or conversation history are sent to external servers. All data is stored locally in your browser.
MIT
To use this extension with the Gemini Nano API, you need to enable the Chrome AI features as described in the setup instructions. This feature is currently part of an Origin Trial and may change before the stable release.