thallus
v0.3.3
Published
Opinionated WXT browser-extension framework: typed messaging, storage, settings, auth, security, browser API wrappers, a React design system, and build/release tooling
Maintainers
Readme
thallus
An opinionated framework for building browser extensions with WXT. Typed IPC, storage, settings, auth, HTTP, permissions, content scripts, a React design system and release/store tooling — as small composable modules. Write a feature once, activate it on the surfaces you need, and ship to Chrome, Edge, Firefox and Safari.
pnpm add thallus wxtWhat you get
| Area | Highlights |
| --- | --- |
| Foundation | Typed env + feature flags, scoped logger, ExtensionError, browser/OS detection, lifecycle events, manifest merging |
| Modules & WXT | Define a module once, activate per surface (background, content, popup, options, side panel, offscreen); config wrapper, base manifest, stable dev IDs, persistent dev profiles |
| Messaging & storage | Typed request/response + events with schema validation, sender policy, timeouts, retry and cancellation; local/sync/session storage, versioned state, TTL cache, IndexedDB, encryption |
| Networking & state | ky HTTP client with auth headers, retries, upload/download, stream, SSE and WebSocket; offline gating; TanStack Query and Zustand wiring |
| Auth & security | Session store, login/logout/restore, token refresh, browser identity login; CSP checks, origin validation, sanitization, secret redaction, encrypted storage |
| Browser runtime | 20 injectable wrappers (tabs, windows, cookies, downloads, scripting, notifications, alarms, bookmarks, history, …), commands, context menus, permissions, tab groups, task queues, caching, offline sync |
| Content & files | DOM/selector waits, mutation + URL observers, shadow DOM, page metadata/links/media, HTML→Markdown, readability, sanitization, file picker, CSV, export/import, drag & drop, download manager |
| UI & i18n | React design system (shadcn/ui on Base UI), light/dark themes, popup/options/side-panel layouts, RHF + Zod forms, locale store, plurals, Intl formatting |
| Quality & release | Vitest browser/storage/event mocks and fixtures, build/manifest/version helpers, Chrome/Edge/Firefox store metadata + publish plans, CI workflows, deprecation and breaking-change checks |
Every area has a runnable example in the usage guide. lib/ is
React-free and ships only two runtime dependencies: ky and zod.
Quick start
Register the authenticated-download handler in your background entrypoint:
// entrypoints/background.ts
import { registerAuthenticatedDownloadHandler } from 'thallus';
export default defineBackground(() => {
registerAuthenticatedDownloadHandler();
});Call it from a content script, popup or side panel:
// anywhere in the extension
import { requestAuthenticatedDownload } from 'thallus';
await requestAuthenticatedDownload({
url: 'https://example.com/report.pdf',
filename: 'report.pdf', // optional; derived from the URL when omitted
useCredentialsFetch: true, // fetch with session cookies, then save the blob
});Add the downloads permission to your manifest. Defaults are env-driven
(WXT_DOWNLOAD_CONFLICT_ACTION, WXT_DOWNLOAD_SAVE_AS,
WXT_DOWNLOAD_USE_CREDENTIALS_FETCH) — see the usage guide.
Agent skill
This repo ships a comprehensive skill so coding agents can use the framework without
reading the source. thallus covers using the framework; framework-development
covers changing this repo.
# install globally (Claude Code, OpenCode, Cursor, Codex, …)
npx skills add streamwhite/extension-dev-template -g
# list skills, or install one explicitly
npx skills add streamwhite/extension-dev-template --list
npx skills add streamwhite/extension-dev-template --skill thallusThe router lives in .agents/skills/thallus/SKILL.md
and delegates to reference/{core,wxt-modules,browser-runtime,networking,data-auth-security,content-settings,ui-testing,release-store-ci}.md.
Repository layout
lib/ publishable framework (React-free, relative imports)
ui/ React design system, themes and layouts (repo only, not published)
entrypoints/ WXT background/content/popup demo surfaces
shared/ demo modules, protocol and settings
testing/ browser/storage/event mocks, fixtures, render helpers (repo only)
examples/ quick-note — a consumer extension that depends on `thallus`
locales/ en/zh catalogs shipped with the package
scripts/ dev-profile tooling
.agents/skills/ thallus + framework-development agent skills
docs/ usage guideThe published package is a single ESM entry (dist/lib/index.js) built from lib/.
ui/, testing/, entrypoints/ and examples/ stay in the repo.
Documentation
| Doc | Contents | | --- | --- | | Usage guide | Examples for every feature area, from env parsing to store publishing | | Example extension | A complete WXT consumer using the package by name | | Publishing | Verify, bump, publish to npm, and release browser builds | | Agent skills | How agents should use and extend the framework |
Requirements
- WXT
>=0.20.0(peer dependency) and a bundler-based build — WXT, Vite, webpack or esbuild all work. - ESM only. The entry uses extensionless relative imports and imports
wxt/browser, so plain Node ESMimportis not supported. - Runtime dependencies:
kyandzod. React, TanStack Query, Zustand, Tailwind and shadcn are dev dependencies used by the repo'sui/layer.
Development
pnpm install
pnpm test # full vitest suite
pnpm dev # run the template extension (also generates .wxt types)
pnpm build:lib # build the publishable library into dist/
pnpm pack # preview the published tarballThe repo is the library source (lib/), the reusable UI layer (ui/), the WXT
entrypoints used as a template demo, and a consumer example in examples/quick-note/.
See EXAMPLE.md for the example workflow.
Persistent dev profile & auto-pin
pnpm dev launches Chrome with a persistent profile at .wxt/chrome-data
(WXT_CHROME_DATA_DIR), so site logins survive extension reloads. Before the
browser opens, the build:done hook calls prepareDevProfile() to pin the
unpacked extension into that profile (Default/Preferences →
extensions.pinned_extensions), so the toolbar icon is visible in dev without
manually pinning it.
- The extension ID is stable: the manifest ships
key: resolveExtensionPublicKey(), andresolveDevExtensionId()derives the matching ID from it. - Disable with
WXT_DEV_AUTO_PIN=false; override the ID withWXT_DEV_EXTENSION_ID. - Consumer projects get this automatically from
createExtensionConfig()(passdevProfile: falseto opt out). - Chrome/Chromium only — it edits a Chrome profile preference; Firefox has no equivalent.
Publishing
See PUBLISHING.md for the full guide. Verification runs first, the
version bump last:
pnpm release:prepare # build → tests → tarball check → bump version
pnpm release:prepare --verify-only # checks only
pnpm publish # prepublishOnly builds dist/ and validates the artifactLicense
Apache License 2.0 © 2026 Henry He. See NOTICE for
attribution. Third-party dependencies keep their own licenses.
