Search docs

Jump between documentation pages.

Vercel

Vercel has two standalone places you can mount a DaloyJS REST API handler — Node.js Functions and Edge Functions. Each target expects a slightly different export shape; the underlying app object is identical.

When to choose Vercel

  • You want a standalone DaloyJS REST API on Vercel Functions.
  • You want Fluid compute (the default since 2025) with per-request billing.
  • You want preview deployments per PR with zero CI config.

Scaffold

The current Vercel starter creates an Edge Function REST API. If you prefer the Node.js runtime, use the toFetchHandler entrypoint shown below.

bash
pnpm create daloy@latest my-api --template vercel-edge
cd my-api
pnpm vercel dev

1. Vercel Node.js Functions (standalone API)

For a standalone DaloyJS REST API on the Node.js runtime, use a catch-all file in /api. Vercel Node.js Functions expect a default export with a fetch method.

ts
// api/[...path].ts
import { toFetchHandler } from "@daloyjs/core/vercel";
import { app } from "../src/server.js";

// Node.js is the default runtime. No runtime export needed.
export default toFetchHandler(app);

2. Vercel Edge Functions (standalone API)

ts
// api/[...path].ts
import { toWebHandler } from "@daloyjs/core/vercel";
import { app } from "../src/server.js";

export const runtime = "edge";
export default toWebHandler(app);

toEdgeHandler is still exported as a backward-compatible alias of toWebHandler; new code should prefer toWebHandler.

vercel.json

Most projects don't need vercel.json at all. Add it for per-function memory/duration limits or to pin a region.

json
{
  "functions": {
    "api/[...path].ts": { "memory": 1024, "maxDuration": 30 }
  },
  "regions": ["fra1"]
}

The legacy builds property is deprecated — use functions instead.

Deploy

bash
# preview
pnpm vercel deploy

# production
pnpm vercel deploy --prod

# env vars (encrypted)
pnpm vercel env add SESSION_SECRET production

Storage

Vercel KV and Vercel Postgres no longer exist as Vercel-owned products. They were sunset in December 2024 and existing stores were migrated automatically — Vercel KV to Upstash Redis, Vercel Postgres to Neon. For new projects, add the equivalent integration from the Vercel Marketplace (Neon for Postgres, Upstash for Redis) — the integration provisions the store and injects the connection env vars into your project.

Vercel Blob and Edge Config are still first-party Vercel products. See Neon for the Postgres setup and distributed rate-limit store for the Redis setup.

Gotchas

  • Edge runtime has no node:*— keep middleware portable, and prefer fetch-based drivers (Neon serverless, PlanetScale, Turso) when running on Edge.
  • Standalone Vercel Node functions want a default export with { fetch }. Use toFetchHandler.
  • Vercel sets process.envon Node functions; on Edge, secrets are bundled at build time, so don't read them outside the handler.

See also