Edge Compatibility
JSORM is designed to work in any modern runtime, not just Node.js.
Supported runtimes
Section titled “Supported runtimes”- Edge: Cloudflare Workers, Vercel Edge Functions
- Serverless: AWS Lambda, Google Cloud Functions
- Node.js: 22+
- Browser: for clients that talk directly to the DB
Note:
@jsorm/compileris NOT edge-compatible. It usesnode:cryptofor sync HMAC cursors. The PostgreSQL provider requires Node.js 22+ (syncnode:crypto); it does not work on Bun, Deno, or Web Crypto runtimes.
Layer separation makes it possible:
- Core (
@jsorm/core) — Metadata and types only. No runtime dependencies. - Client (
@jsorm/client) — Builds AST. Nofs,path,process, or Node APIs. - Compiler (
@jsorm/compiler) — Shared SQL generation. NOT edge-compatible (usesnode:crypto). - Provider — You select the right provider for each environment.
Example: Cloudflare Workers
Section titled “Example: Cloudflare Workers”import { jsorm, User } from "./models/jsorm.server.js";
export default { async fetch(request: Request) { const { data: users } = await jsorm.users.get({ where: { active: true }, });
return new Response(JSON.stringify(users)); },};Example: Node.js
Section titled “Example: Node.js”import { jsorm, User } from "./models/jsorm.server.js";
const { data: users } = await jsorm.users.get({ where: { active: true },});
console.log(users);Same API. Same code. Only the registered provider changes.
