Hatch
On this page

How to run Hatch from this repo, what each package does, and the checks to run. Agents: read AGENTS.md first.

Run it

pnpm install
pnpm dev            # web, http://localhost:5173
pnpm dev:desktop    # desktop app, opens ~/Documents/Hatch
pnpm test           # unit tests
pnpm typecheck

Open another folder on desktop with HATCH_VAULT=/path/to/vault pnpm dev:desktop, or use the vault button in the sidebar.

Accounts (optional)

pnpm --filter @hatch/server start            # http://localhost:8787, SQLite in apps/server/data
VITE_HATCH_SERVER=http://localhost:8787 pnpm dev

To open the app from another device (a phone on your Tailscale network, say), serve the account server through the dev server so both share one address: VITE_HATCH_SERVER=/ HATCH_DEV_SERVER=http://localhost:8787 pnpm dev. Add that address to the server's HATCH_ORIGINS, and to Vite's allowed hosts with __VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS=<host>.

Add VITE_HATCH_REQUIRE_ACCOUNT=true to require sign-in before using the app. The same server stores synced vaults and published sites in SQLite.

Publishing settings on the server:

  • HATCH_SITES_HOST=sites.example.com gives every site its own address, like notes.sites.example.com. Point a wildcard DNS record at the server. Private sites need this. For local testing, sites.localhost:8787 works in Chrome.
  • Without it, sites are served at /s/<address>/ in a sandbox, and only public sites are allowed.
  • HATCH_MAIL=resend or postmark, with HATCH_MAIL_KEY and HATCH_MAIL_FROM, sends email. Invite-only sites need it, because invited people sign in with a link sent to their email. HATCH_MAIL=log prints email instead, for development.
  • Email updates for sites also need HATCH_MAIL. With Postmark, set HATCH_MAIL_BROADCAST_STREAM to your broadcast stream.
  • HATCH_ABUSE_EMAIL gets abuse reports about hosted sites, with a link to take a site down. See deploy.md.
  • HATCH_ERROR_DSN sends crash reports from the server, and VITE_HATCH_ERROR_DSN from the apps (at build time). Reports never include note content. See errors.md.
  • HATCH_MAX_SITES (default 10), HATCH_MAX_SITE_BYTES (default 500 MB) and HATCH_MAX_SUBSCRIBERS (default 5000 per site) set the limits.

Plans and billing (optional):

  • STRIPE_SECRET_KEY turns on plans. Accounts start on Free and pay for Pro or Careers through Stripe Checkout. Products, prices and the billing portal's settings are made in Stripe on first use. Without it, every account gets every feature, up to the limits above.
  • STRIPE_WEBHOOK_SECRET is the signing secret of a webhook endpoint at https://<server>/api/billing/webhook, sending checkout.session.completed and customer.subscription.created, .updated and .deleted. Plans only change when Stripe calls it, so the server won't start with a key but no webhook secret.
  • Plans, their prices and what each turns on are in apps/server/src/plans.ts. A plan can lower a limit, never raise it past the server's.

Mobile

cd apps/mobile
pnpm add:ios        # once, needs Xcode
pnpm ios            # builds, syncs and opens Xcode

Android works the same way with add:android and android.

Layout

Every package is standalone and could live in its own repo.

PackageWhat it does
@hatch/markdownMarkdown parser and serializer. Lossless for unchanged blocks
@hatch/vaultFiles, index, link resolution, backlinks, search, attachments
@hatch/editorEditor kit on ProseMirror with a typed extension API
@hatch/plugin-apiPlugin host, permissions, community plugin loader
@hatch/pluginsThe built-in plugins
@hatch/themeTokens, built-in themes, contrast checks, theme files
@hatch/platformThe only shell-specific seam: web, desktop, mobile
@hatch/accountOptional account client (bearer tokens)
@hatch/syncTwo-way file sync engine with conflict-safe writes
@hatch/importImporters, with their own HTML parser and zip reader
@hatch/publishVault to website: docs, blog and portfolio templates, search, RSS, SEO
@hatch/blocksMarkdown components: chart, progress, tabs, button, toc, form. Checks, suggestions and HTML
@hatch/highlightSyntax highlighting for code blocks, colored by theme tokens
@hatch/appThe React UI shared by all three apps
@hatch/mcpMCP server over a vault

Apps: apps/web, apps/desktop, apps/mobile, and apps/server (Hono and Better Auth).

Checks

scripts/check.sh runs all of these: typecheck, unit tests and every browser suite, with its own builds and servers. scripts/check.sh quick skips the browser suites. Working on the code with an agent? Start with AGENTS.md, which lists every command.

CommandWhat it covers
pnpm testMarkdown round-trip and edit safety, editor bridge, vault, plugins, themes, MCP, accounts
python3 scripts/e2e.py <url>Typing, shortcuts, tasks, links, image paste, palette, undo
python3 scripts/e2e-safety.py <url>Agent appends, outside edits, rename and delete races, vault switch, failed saves
python3 scripts/e2e-plugins.py <url>Community plugin consent, lifecycle and sandbox isolation, panels in frames, community themes
python3 scripts/e2e-images.py <url>Image resizing, full-size view, attachments panel
python3 scripts/e2e-theme-studio.py <url>Making and saving a theme
python3 scripts/a11y-check.py <url>Keyboard and focus behavior from the accessibility audit
python3 scripts/e2e-sync.py <url>Two devices: link, edit, conflict, new notes (needs the server)
python3 scripts/e2e-sharing.py <url>Two accounts: invite, accept, edit both ways, remove (needs the server)
python3 scripts/e2e-publish.py <url>Build, download, publish and share a site (needs the server)
python3 scripts/e2e-canvas.py <url>Canvas boards: draw, connect, keyboard, save
python3 scripts/e2e-git-backup.py <url>Git backup, history and restore, against a fake GitHub
python3 scripts/e2e-history.py <url>Version history on this device: compare, copy, restore, renames, deleted notes
python3 scripts/e2e-import.py <url>Notion import through the dialog
python3 scripts/e2e-bigvault.py <url>3,000-note folder: virtualized tree, keyboard reach, reveal
python3 scripts/perf.py <url>Startup, large-note typing latency, save cost, search latency
npx tsx bench/vault.bench.tsIndex, search and backlinks on a 5,000-note vault

Past reviews and their fixes are in reviews/.