ZTS Docs

Browser extension

WXT extension in apps/extension sharing Better Auth and tRPC with the web app.

The browser extension (apps/extension, @zts/extension) is built with WXT. It reuses the web app’s Better Auth session and /api/trpc endpoint.

Develop

  1. Start the web app from the monorepo root: pnpm dev
  2. Configure trusted origins in .env:
    BETTER_AUTH_TRUSTED_ORIGINS=chrome-extension://*
    For production, use the unpacked extension ID from chrome://extensions (also shown on the extension options page).
  3. Run the extension: pnpm dev:extension
  4. Load the unpacked build from apps/extension/.output/chrome-mv3-dev in Chrome

Configuration

  • Options page: set the web app URL (default http://127.0.0.1:3000)
  • tRPC client: apps/extension/src/lib/trpc-client.ts{baseUrl}/api/trpc
  • Auth: apps/extension/src/lib/extension-auth-client.ts shares cookies on the web origin

Features

  • Popup sign-in / sign-up / password reset (same Better Auth API as web and mobile)
  • Session via cookies on the web app origin
  • Signed-in popup: user summary, billing state, links to app settings
  • Background bridge for session sync and opening app tabs

Build

pnpm build:extension

Output: apps/extension/.output/chrome-mv3

On this page