Netlify
Netlify gives you two runtime options for an API: Edge Functions (Deno-based, global) and Functions v2 (Node, fetch-style). Both call your default export as (request, context) => Response, so the DaloyJS adapter is the same helper in both places. Only the file location and the optional config export change.
When to choose Netlify
- You want a platform-managed REST API with Edge or Node function options.
- You want preview deploys per branch with zero config.
- You're fine with platform-managed cold starts.
What the adapter adds
toNetlifyHandler(app) from @daloyjs/core/netlify (since 1.16.0) is a thin wrapper over app.fetch, but it reads two things from Netlify's context that a generic fetch handler cannot see:
context.ipis the client address Netlify's edge observed on the TCP connection. The adapter attaches it as the request's connection info, sobehindProxy: "none"(the right posture when Netlify is the only thing in front of you) resolves the real client forrateLimit(),autoBan(),ipRestriction(), and audit logs instead of putting every caller in one shared bucket. It is never read from a spoofable header, and a value that is not an IP literal is ignored, not trusted.context.waitUntilkeeps the invocation alive until the OTLP telemetry flush finishes, instead of the flush being dropped when the function returns.
If you put a CDN in front of Netlify, declare it with behindProxy: { cidrs: [<CDN egress ranges>] }, not { hops: 1 }. Only the cidrs form checks that the socket peer — context.ip here — is one of your proxies before trusting a forwarded header; hops reads the header whenever it is present. Because a Netlify site stays reachable on its *.netlify.app origin behind any CDN, a direct caller could otherwise spoof X-Forwarded-For and rotate their rate-limit or ban identity, which is exactly what context.ip was added to prevent.
The adapter has no dependency on @netlify/functions or @netlify/edge-functions; the NetlifyContext type it accepts is structurally compatible with both.
Netlify Edge Functions (Deno)
Edge Functions run on a Deno-based runtime. Use toNetlifyHandler; the input/output shape is identical to Functions v2.
Netlify Functions v2 (Node, fetch-style)
Functions v2 is GA and is the recommended way to write Node functions on Netlify. The old v1 lambda-style handler (exports.handler = (event, context) => ...) is legacy. It still works for compatibility but you should write new code in v2.
toWebHandler(app) from @daloyjs/core/vercel still works on Netlify if you only need Request -> Response, but it cannot see context.ip, so every client lands in one rate-limit bucket unless you declare a proxy posture.
If you have an existing v1 codebase you can't migrate yet, the Lambda adapter still works against the v1 event shape:
netlify.toml
For a REST-API-only project there is no static site to publish. Omit the publish key (or point it at an empty directory) so Netlify doesn't try to serve your compiled server code as static files.
Deploy
Gotchas
- Edge Functions don't expose
node:*, the same caveat as Vercel and Cloudflare Workers. - Functions v2 returns a
Responsedirectly. Don't use the v1statusCode/bodyobject shape in v2 code. context.waitUntilis available in v2 for fire-and-forget work; the adapter already uses it for the telemetry flush.