What Is a Netlify Function? Serverless, Explained
A Netlify Function is a piece of backend code — usually a single JavaScript file — that runs on demand when a URL is hit, without you running a server. It’s the technology behind every contact form, payment flow, and AI feature on my own sites, so this is an explainer with receipts.
The problem it solves
Static sites are fast, cheap, and secure — but purely static means no secrets and no server-side work. You can’t put a mail password or a Stripe key in front-end JavaScript (everyone can read it), and you can’t process a payment in the browser. The old answer was “rent a server, run Node/PHP 24/7, patch it forever.” The serverless answer: keep the static site, and deploy tiny functions that wake up only when called.
How it actually works
You drop a file in netlify/functions/ — say contact.mjs — and Netlify gives it a URL (/.netlify/functions/contact, usually remapped to something clean like /api/contact). When a request hits that URL, Netlify spins up your code, runs it with access to environment variables (your secrets, stored in Netlify’s dashboard, never in the repo), returns the response, and shuts down. You pay nothing for idle time, and the free tier covers a small business’s realistic volume comfortably.
What people build with them
Contact forms that send real email via SMTP (mine route through Zoho to a business inbox, with honeypot spam filtering). Stripe checkout and webhooks — creating payment sessions and verifying them server-side, which is exactly how my products sell without any login system. AI endpoints — the browser calls your function, your function calls the Claude API with your key, and the key never touches the client. Gated content — issuing and verifying signed passes so paid content stays paid. Every one of those runs in production on my own sites right now.
Honest limits
Functions are for short, stateless work — they have execution time limits (seconds, not hours) and keep no memory between calls, so state lives in a database or signed tokens. Long jobs belong in background functions or a different tool. And debugging is log-based; you’ll live in the function logs, not a debugger. None of this bites a typical business site; it bites people trying to run a video encoder in a form handler.
Why this stack wins for small business
Static front-end + a handful of functions = the whole “server” a most businesses need, with no machine to patch, no monthly server bill, and secrets kept server-side. It’s the default architecture for everything I ship — and wiring one up (form, payment, AI feature, or all three) is a small, fixed-scope job. If you’re weighing this against buying an off-the-shelf tool, that decision has its own guide.
FAQ
There's a generous free tier (125k requests/month) that comfortably covers a typical small-business site's forms and features; beyond that it's pay-per-use. You pay nothing for idle time.
JavaScript/TypeScript (Node) is the mainstream path; Go is also supported. Most examples, tooling, and libraries assume Node.
Netlify Functions are AWS Lambda under the hood with the DevOps removed: deploys ride your site's git push, URLs and env vars are automatic, and logs live in the same dashboard as your site.
Functions are stateless between calls — state belongs in a database (like MariaDB/Postgres), a KV store, or signed tokens. Each invocation starts fresh.
Related guides
Want it built instead?
Automation, tools, and apps — scoped, quoted, and shipped to production.