#45
Migrate Redakt to TanStack Start
Summary
- replace Next.js completely with TanStack Start, TanStack Router, and TanStack Query
- port public, authenticated, mail, settings, AI, and external API routes while preserving nested mailbox layouts
- switch the production build, runtime, and container to Nitro output
- add the completed migration plan and update project tooling and documentation
Validation
pnpm test(169 passed)pnpm lintpnpm typecheckpnpm build- production Docker image build plus health and SSR inbox smoke tests
- desktop and 390px browser QA across inbox, conversation, Focus, and settings with no browser errors
- Next.js residue, lockfile, client-boundary, and diff-hygiene scans
Follow-up after merge candidate deployment
- verify live Better Auth and Gmail OAuth against staging credentials
- verify the staging health endpoint and production-like Railway rollout
Activity
4mikeyreviewed2mo ago
6b814ac into main2mo ago
Review: Migrate Redakt to TanStack Start (#45)
Reviewed this as a framework port rather than a fresh feature: for every changed route/handler I diffed the old Next.js implementation against its new TanStack Start counterpart, with special attention to auth checks, ownership/tenant-scoping, and any place a check could be silently dropped during the port. I split the surface into four areas and verified each independently (checked out
pr-45@c890860against base40b4a27locally, read both sides of every pair, not just the diff hunks).Auth & sessions (
src/server/auth.server.ts,auth.functions.ts,lib/auth-core.ts,_authenticatedlayout guard,src/routes/api/auth/**, session revoke endpoints): Better Auth config is byte-for-byte preserved aside from swappingnextCookies()fortanstackStartCookies(). Every previously-protected page underapp/mail/**has a matching file undersrc/routes/_authenticated/mail/**gated by the samebeforeLoadsession check, and every API handler still independently re-checks the session server-side. Session revoke endpoints still scope to the caller's own sessions only. The oldproxy.tsmiddleware (cache headers + demo-sandbox cookie seeding) was reimplemented asrequestMiddlewareinsrc/start.ts, and a new CSRF middleware for server functions was added (net addition, not a regression).Mail API (
src/routes/api/mail/**,src/server/mail.functions.ts,mail-provider.server.ts): the single choke point for account/thread/attachment ownership,resolveMailAccount(user, accountId), is unchanged and still called before every mail operation. Google Pub/Sub webhook JWT verification (issuer/audience/service-account/email_verified) is byte-identical to the old route — no auth bypass introduced. Send/compose/draft validation preserved.Settings & domains API (
src/routes/api/settings/**,src/routes/api/domains*): password-change current-password check, domain ownership check (getUserDomainstill rejectsrow.userId !== user.id), and session-revoke scoping all preserved. All six old settings endpoints have 1:1 new counterparts — nothing silently dropped.Route tree / build / deploy (
src/start.ts,vite.config.mts,Dockerfile, mailbox nested routes,tsconfig.json): no server secrets leak into the client bundle (a customserverOnlyBoundaryVite plugin enforces this), Dockerfile correctly targets Nitro's.outputlayout instead of stale.next/standalonepaths, and theaccountId-scoped nested mailbox routes preserve the same nesting and redirect behavior as the oldapp/mail/a/[accountId]/**tree.Non-blocking follow-up
src/routes/api/mail/threads/$id.ts(PATCH) dropped the old route'srevalidateTag(mailAccountCacheTag(...), { expire: 0 })call — that was Next.js-specific cache invalidation with no direct TanStack Start equivalent in the new code. Not a security issue, but if any server-side response caching still sits in front of thread/folder reads, a mutation could serve stale data until TTL expiry. Worth a quick check post-merge; not blocking.No blocking correctness or security issues found. This PR is safe to merge from this pass.