显示HN:BAREmail ʕ·ᴥ·ʔ – 适用于糟糕WiFi的极简Gmail客户端
Show HN: BAREmail ʕ·ᴥ·ʔ – minimalist Gmail client for bad WiFi

原始链接: https://github.com/matt-virgo/baremail

## Baremail:轻量级 Gmail 客户端 Baremail 是一款极简的渐进式 Web 应用 (PWA),专为低带宽环境设计——例如飞机 WiFi 或农村连接——在这些环境下,完整的 Gmail 界面过于臃肿。它提供基本邮件功能,体积小巧:gzip 压缩后不到 200KB,并且在首次加载后仅使用 Gmail API JSON 数据进行网络传输。 主要功能包括带有指示器的收件箱查看、星标和归档、打字机效果的纯文本阅读、撰写/回复、搜索、标签(收件箱、星标等)以及浅色/深色主题。它采用离线优先的设计,允许用户阅读缓存的邮件并在没有连接的情况下排队发送消息。 设置过程涉及一个引导向导,通过 Google Cloud 项目连接到 Gmail API——无需编码。它可以作为 PWA 安装,实现即时加载,并且可以直接在浏览器中使用。Baremail 优先考虑速度和可访问性,旨在在具有挑战性的网络条件下提供可用的邮件体验。它是开源的(MIT 许可证),并专注于保持其尺寸最小化以实现最佳性能。

## BAREmail:低带宽下的极简Gmail客户端 一个名为**BAREmail**的新开源项目旨在解决在不可靠的网络连接(如飞机WiFi)上使用臃肿邮件客户端的问题。由Virgo_matt创建,它是一个极简、纯文本的Gmail客户端,设计用于在带宽受限时快速发送简单邮件。 开发者对现有客户端的性能感到沮丧,因此构建了BAREmail,使其轻量且快速,使用Google Cloud Platform设置大约需要3分钟。 Hacker News上的讨论引发了关于替代邮件客户端和协议的对话。许多评论者指出可以使用利用IMAP/POP3的传统桌面客户端,而另一些人则强调了这些客户端与现代多因素身份验证以及Gmail API的专有性质带来的挑战。 许多用户赞扬BAREmail注重易用性及其在旅行中的适用性。
相关文章

原文

Email's bare necessities. A minimalist Gmail client for low-bandwidth environments — airplane wifi, rural connections, developing regions, or any situation where Gmail's full interface is too heavy.

  ʕ·ᴥ·ʔ
  BAREMAIL
  ── email's bare necessities ──

BAREMAIL

BAREMAIL is a Progressive Web App that talks directly to the Gmail API. The entire app shell is under 200KB gzipped, cached by a service worker, and then the only network traffic is Gmail API JSON — the UI itself costs zero bytes on repeat visits.

  • App shell: ~60KB gzipped (Preact + HTM + your styles and logic)
  • Inbox load: ~3-5KB of API data for 25 messages
  • Single email: ~1-3KB for a typical text message
  • Offline-first: read cached emails, compose and queue messages with no connection
  • Zero-install: works in any modern browser, installable as a PWA
  • Inbox with unread indicators, starring, and archive
  • Mobile compatible progressive web app
  • Plain text message reader with typewriter effect
  • Compose, reply, and forward (plain text)
  • Search via Gmail's query syntax
  • Labels: Inbox, Starred, Sent, Drafts
  • Light/dark theme (respects system preference)
  • Keyboard shortcuts (j/k navigate, o open, c compose, r reply, e archive)
  • Offline compose with outbox queue and background sync
  • Connection status indicator with bandwidth estimates
  • Inbox zero bear mascot with animated ASCII scenes
  • Hidden mini-game: Honey Catcher

Open http://localhost:3000 and the built-in setup wizard walks you through connecting to Gmail:

  ʕ·ᴥ·ʔ  BAREMAIL

  ʕ·ᴥ·ʔ setup guide                     ~3 minutes
  ● ○ ○ ○ ○ ○
  step 1 of 6

  ┌─────────────────────────────────────────────┐
  │  create a google cloud project              │
  │                                             │
  │  click the link below to create a new       │
  │  google cloud project. name it anything     │
  │  you like (e.g. "BAREMAIL").                │
  │                                             │
  │  ┌───────────────────────────────┐          │
  │  │ open google cloud console →   │          │
  │  └───────────────────────────────┘          │
  │                                             │
  │  ▸ need a google account?                   │
  └─────────────────────────────────────────────┘
              ┌──────────────────────┐
              │  done, next step →   │
              └──────────────────────┘

The wizard has 7 steps (one optional) — each one opens the exact Google Cloud page you need, tells you what to click, and lets you paste your credentials directly into the app. No config files to edit.

Video walkthrough: Watch the setup wizard in action

On first sign-in, you'll see a warning: "Google hasn't verified this app." This is normal for development. Click AdvancedGo to BAREMAIL (unsafe) to continue. Your data still goes directly to Google's API, never through a third party.

Alternative setup methods

CLI setup (interactive):

Opens each Google Cloud page in your browser and prompts for credentials in the terminal. Writes config.js automatically.

Manual config file:

cp config.example.js config.js

Edit config.js and paste your Client ID and Client Secret:

window.BAREMAIL_CONFIG = {
  GOOGLE_CLIENT_ID: 'your-client-id.apps.googleusercontent.com',
  GOOGLE_CLIENT_SECRET: 'your-client-secret',
  GOOGLE_REDIRECT_URI: window.location.origin,
};

Note on the client secret: This is visible in the source code, which is expected for browser-based apps using Google's "Web application" OAuth type. The PKCE flow protects against authorization code interception, and the secret alone can't access anyone's data without user consent.

Manual steps reference:

  1. Create a Google Cloud project
  2. Enable the Gmail API
  3. Configure OAuth consent screen — select External, fill in app name + emails
  4. Add yourself as a test user — scroll to Test Users, add your Gmail address
  5. (Optional) Set up ngrok for mobile — see Install on iPhone / iPad below
  6. Create OAuth credentials — Web application, add http://localhost:3000 to origins and redirect URIs (plus your ngrok URL if using mobile)
  7. Paste Client ID and Client Secret into the app or config.js

Install as a PWA (use from your dock)

BAREMAIL is designed to be used as an installed app, not a browser tab. Once installed, the service worker caches everything locally — the app launches instantly from your dock and API calls go directly to Gmail. No server needed after installation.

Chrome (recommended):

  1. Visit http://localhost:3000
  2. Click the menu (top-right) → Cast, save, and shareInstall page as app...
    • Alternatively, look for the install icon (⊕) in the address bar — but this doesn't always appear
  3. BAREMAIL now appears in your dock, Launchpad, and Spotlight

Safari (macOS Sonoma+):

  1. Visit http://localhost:3000
  2. Go to File → Add to Dock
  3. BAREMAIL appears in your dock

After installation:

  • Just click the BAREMAIL icon in your dock — it opens in its own window, no browser chrome
  • The service worker serves the app from cache, so it launches instantly even if npm start isn't running
  • To update the app after pulling new code: run npm start once, open BAREMAIL, and the service worker will pick up the new version in the background

PWAs require HTTPS, so you'll need to tunnel your local server to get a public URL. ngrok is the simplest way.

One-time setup:

  1. Install ngrok:
    brew install ngrok    # macOS
    # or download from https://ngrok.com/download
  2. Create a free account at ngrok.com and run:
    ngrok config add-authtoken YOUR_TOKEN

Expose your local server:

  1. Make sure BAREMAIL is running (npm start)
  2. In a separate terminal:
  3. Copy the https://xxxx.ngrok-free.app URL from the output

Add the ngrok URL to Google OAuth:

  1. Go to Google Cloud Console → Credentials
  2. Click on your OAuth client ID
  3. Add the ngrok URL to both Authorized JavaScript origins and Authorized redirect URIs
  4. Click Save

Install on your phone:

  1. Open Safari on your iPhone (must be Safari — other browsers on iOS don't support PWA installation)
  2. Navigate to your https://xxxx.ngrok-free.app URL
  3. If ngrok shows an interstitial page, tap through it
  4. BAREMAIL will show the setup wizard — enter the same Client ID and Client Secret you used on your computer
  5. Sign in with Google
  6. Tap the Share button (square with arrow) → "Add to Home Screen""Add"
  7. Open BAREMAIL from your home screen — it will show the setup wizard one more time (iOS uses separate storage for home screen apps). Enter your credentials again and sign in.

After that, BAREMAIL is fully installed. The service worker caches everything locally, so the app will keep working even after you shut down ngrok. You only need ngrok again to push new versions of the app to your phone.

Note: ngrok's free tier generates a new URL each time you restart it. If you restart ngrok, you'll need to update your Google OAuth credentials with the new URL and re-add the PWA on your phone.

Command Description
npm start Production build + serve on port 3000 (use this)
npm run setup Interactive setup — opens GCP pages and writes config.js
npm run dev Dev server with sourcemaps (for development)
npm run build Production build to dist/ (for deployment)
npm run watch Watch mode, rebuilds on change

For personal use, npm start + PWA install is all you need. If you want to host it on a public URL:

BAREMAIL is just static files — deploy the dist/ folder anywhere:

  • Cloudflare Pages: connect your repo, build command npm run build, publish directory dist
  • Netlify / Vercel: same setup
  • GitHub Pages: push dist/ to a gh-pages branch

Update your Google OAuth credentials with the production domain:

  • Authorized JavaScript origins: add https://yourdomain.com
  • Authorized redirect URIs: add https://yourdomain.com
  • Add any users who need access as test users on the OAuth consent screen (until you go through Google's verification process)
Browser
├── App Shell (Preact + HTM, cached by service worker)
│   ├── Inbox view (message list, search, pagination)
│   ├── Reader view (plain text, attachments list)
│   ├── Compose view (send/reply/forward, offline queue)
│   └── Components (header, nav, footer, bear mascot)
├── Service Worker
│   ├── Cache-first for app shell
│   ├── Network-first for Gmail API
│   └── Background sync for outbox
├── IndexedDB
│   ├── Message cache (LRU, 1000 messages)
│   ├── Outbox queue
│   └── User preferences
└── Gmail REST API (direct, no backend)

BAREMAIL runs entirely in your browser. There is no backend server. Your emails go directly between your browser and Google's Gmail API. No data is ever sent to a third party.

OAuth tokens are stored locally. The app requests only the minimum scopes needed: read, send, and modify (for marking read/unread and archiving).

Layer Choice Size
Framework Preact + HTM ~4KB gzipped
Language TypeScript Zero runtime cost
Styling Single CSS file ~5KB gzipped
Font IBM Plex Mono (subset) ~15KB gzipped
Build esbuild Fast, minimal config
Offline Service Worker + IndexedDB ~5KB
Search MiniSearch (future) ~8KB gzipped
Key Action
j / k Navigate inbox up/down
o / Enter Open selected email
c Compose new email
r Reply to current email
e Archive current email
Esc Back / discard
Cmd+Enter Send message

"Access blocked: This app has not completed the Google verification process" You didn't add yourself as a test user. Go to the OAuth consent screen, click your app, go to the Test users section, and add your Gmail address.

"Error 400: redirect_uri_mismatch" Your OAuth credentials are missing the redirect URI. Go to Credentials, click on your OAuth client, and make sure both Authorized JavaScript origins and Authorized redirect URIs include http://localhost:3000 (exact match, no trailing slash).

"Error 401: invalid_client" Double-check that you copied the full Client ID (it ends with .apps.googleusercontent.com). If using config.js, make sure the file is saved and you restarted the server.

"Google hasn't verified this app" This is expected. Click AdvancedGo to BAREMAIL (unsafe). This warning appears because your app is in testing mode. Your data still goes directly to Google's API.

  • Every PR must not increase the app shell beyond 200KB gzipped
  • Runtime dependencies must be justified by their size-to-value ratio
  • Features must degrade gracefully offline
  • Feature rubric: "does this help on airplane wifi?"

MIT — see LICENSE

If BAREMAIL saved you from staring at a loading spinner on airplane wifi, consider buying the bear a coffee:

      ʕ·ᴥ·ʔ ☕
      |    |/
      |    |    thx for the coffee!
     /|    |\

Buy Me A Coffee

Star History Chart

联系我们 contact @ memedata.com