•
2 min read
Upstream contributions to Cloudflare vinext

vinext is Cloudflare’s reimplementation of Next.js on Vite, built to run on Workers. Our client admin portal depended on Clerk for auth, and vinext flagged Clerk as unsupported. Rather than wait, I read both codebases, found the gaps, and fixed them upstream.

What I shipped

  • #803: Clerk compatibility, unsupported → partial. The “unsupported” label was an assumption, not a test. I built a real app against the live Clerk API, verified public routes, protected-route redirects, sign-in, and authenticated sessions through middleware, and submitted the runtime evidence. Merged, shipped in vinext 0.0.41.
  • #812: stale headers snapshot in middleware. Clerk reads request headers, then rewrites them, and expects the page render to see the rewrite. vinext cached a sealed snapshot on first read and never invalidated it, so every page threw “auth() was called but Clerk can’t detect usage of clerkMiddleware()”. An 18-line fix in applyMiddlewareRequestHeaders(), plus a unit test and an end-to-end regression test that fail before and pass after. Full matrix green: 2,813 unit, 1,252 integration, 302 app-router E2E, 37 Workers E2E.
  • #819: self-hosted next/font/google assets. Emit served URLs for self-hosted font files so they resolve correctly in production builds.

With those merged, Clerk works fully on vinext.

A note on attribution

These PRs were opened from our company GitHub account (now opsidian-agent) rather than my personal one, samhill8. That was my mistake. I wrote all three; I own both accounts.

Write-up: How we got Clerk auth fully working on Cloudflare’s new Next.js platform.