Inspiration
If you read a lot of technical docs, research papers, or long PDFs, you know the loop: highlight something, copy it, jump to a cloud AI chat, paste, wait, then do it all over again. It gets old fast. And it always felt a bit silly to send every random webpage snippet or private local PDF to a remote server, adding latency and giving up privacy, when modern Chrome can run Gemini Nano 4 right on your own machine.
So we set out to build a reading companion that feels like a shot of Espresso: quick, always sitting next to your page in Chrome's Side Panel, on-device first, and only reaching for the cloud when a document really needs it.
What it does
Espresso is a Manifest V3 Chrome Side Panel extension built around what we call a Nano-First Hybrid AI approach:
- Runs on your device first (Gemini Nano 4): When the Side Panel opens, Espresso warms up a local
LanguageModelbase session. Each request then uses a lightweight clone (topK: 1,temperature: 0.2), so selections and everyday pages get fast, free, private answers. - Smart hybrid routing: Espresso checks how big your page or selection is and whether the local model is ready. Everyday reads go to Nano 4, and oversized documents fall back to Gemini Cloud through Firebase AI Logic without any fuss.
- PDFs that stay fully local and offline: Espresso pulls clean article text with Mozilla Readability, or parses local
file://PDFs and file-picker uploads entirely offline with pdf.js. Flip on Local Only at any time and everything stays on your device, with zero network requests. - Four built-in prompts, plus your own: You get Quick Summary, Key Takeaways, Explain Like I'm 5, and Code & Docs Breakdown out of the box. You can also create and pin custom prompts, and optionally sync them across devices with Firebase Auth + Cloud Firestore.
- A friendly 3-step setup guide: Espresso checks
LanguageModel.availability()live and walks you through turning on the Chrome flags and downloading Gemini Nano 4. You can still use Hybrid Cloud mode while you set things up.
How we built it
Espresso is built with React 19, TypeScript, Tailwind CSS v4, and Vite, targeting Chrome Manifest V3 (sidePanel).
1. Getting the right text out of the page
- Selections and webpages: Using
chrome.scripting, Espresso grabs whatever you've highlighted first. If nothing is selected, it falls back to@mozilla/readability, which strips out navbars, ads, and other clutter from the page. - Offline PDFs:
pdfjs-distis bundled inside the extension, so bothfile:///*.pdftabs and files you load with theOpen PDFbutton are parsed locally, with no server upload.
2. Nano-first routing
We didn't want local and cloud AI to feel like two separate products, so routing is a simple, predictable decision based on the user's mode, whether the model is ready, and an estimated token count (roughly length / 4, rounded up):
Route = Nano 4 (On-Device)
if mode is Local Only
OR (Nano is ready AND estimated tokens <= 2,000)
Route = Gemini Cloud (Fallback)
if mode is Hybrid
AND (Nano is not ready OR estimated tokens > 2,000)
The 2,000-token limit is the sweet spot for a clean single-shot run on-device.
If you're in Local Only mode (or the cloud returns a 429 quota error or you're offline) and the document is too long for Nano 4, Espresso trims it at sentence boundaries (up to 4,800 characters). That way you still get an answer instead of an error halfway through your work.
3. Cloud fallback and optional sync
- Firebase AI Logic (
firebase/ai): Cloud responses are streamed, with automatic model fallback (gemini-3.5-flash-lite→gemini-4-hydrogen). - Firebase Auth + Firestore: If you want, you can sign in with email and password and back up your custom prompts under
users/{uid}.
Challenges we ran into
- Cold starts and session lifecycle in Chrome's
LanguageModelAPI. Creating a fresh on-device session on every click caused noticeable lag, and cloned sessions sometimes became invalid between runs. Our fix was to keep awarmBaseSessionaround and rebuild it automatically wheneverclone()throws. - Offline PDF parsing under Manifest V3. Reading
file://URLs needs the user to turn onAllow access to file URLs, andpdf.jsworkers have to be bundled carefully to satisfy MV3's Content Security Policy. We bundled the worker locally with Vite, then added an in-panel helper and a directOpen PDFoption so nobody gets stuck. - Failing gracefully instead of just failing. Most tools show an error toast when cloud quota (
429) runs out or the connection drops. We built a fallback chain that drops back to sentence-trimmed Gemini Nano 4, so Espresso stays useful even on flaky connections.
Accomplishments that we're proud of
- A hybrid experience that really is Nano-first. Everyday reading is fast, free, and private on your device, while long technical specs still work in a single click.
- Zero network traffic, verified. In Chrome DevTools' Offline mode, we summarized multi-page local PDFs with Gemini Nano 4 and saw 0 network requests and 0 B transferred.
- A solid, tested core. Routing, session clone recovery, context trimming, and offline
pdfjs-distextraction are covered by 20 passing Vitest unit tests.
What we learned
- On-device AI works best with clear boundaries. Gemini Nano 4 is impressively fast on focused context (up to 2,000 tokens), and combining it with Mozilla Readability noticeably improves answers by keeping junk out of the context window.
- Setup experience matters as much as the model. Chrome's built-in AI needs specific flags and a one-time model download, which can be confusing. Putting a live 3-step guide right in the Side Panel turned that hurdle into a smooth first-run experience.
What's next for Espresso
- Map-reduce for long PDFs, fully local. Summarize 50+ page documents entirely on-device, with no trimming.
- Context from multiple tabs. Pull together several open research tabs into one structured brief.
- Chrome Web Store launch. Finish production App Check and packaging for a public release.
Built With
- chrome
- firebase
- firebase-ai-logic
- firestore
- gemini-nano
- manifest-v3
- mozilla-readability
- pdfjs
- react
- tailwindcss
- typescript
- vite