EdgeWorkers
Shipping an AI SaaS on Cloudflare Workers
Jun 7, 2026
Running the whole stack — marketing site, dashboard, admin, and API — on Cloudflare Workers sounds aggressive. In practice the constraints are real but few, and they push you toward a cleaner architecture.
Create clients per request
There is no long-lived process to hold a connection pool. Every database client is created inside the request, over Neon's HTTP driver:
const db = createDb(env.DATABASE_URL);
const products = await db.select().from(schema.product);
No module-level I/O, no warm-pool assumptions — which also keeps cold starts small.
No interactive transactions
Neon over HTTP can't hold a transaction open across round-trips. For multi-step
atomicity you reach for db.batch([...]), which Neon runs as a single
transaction, or a single guarded statement.
What surprised us
- TTFB dropped under 100ms globally without touching a single config.
verbatimModuleSyntaxhad to stay off in the web app, or server bundles leak into the client.- Plugin order in
vite.config.tsis load-bearing.
The payoff: one mental model, one deploy target, and latency that's fast everywhere instead of fast near one region.