Netlify: Netlify Lambda Functions Tutorial

Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026

The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.


I wrote about Netlify previously on my Netlify tutorial. I use it to host this blog, and it’s great.

I also use it to run other sites, and all run on Hugo - which makes my stack 100% JAMstack.

The cool thing about JAM is that it’s not all limited to static and “dumb” sites - you can do a LOT of things that are as dynamic as you want.

Most of that power comes in the form of lambda functions.

You can have JavaScript on your site (or plain HTML forms) invoke a URL endpoint, which when called executes some predetermined code. Different providers offer support for various languages. Netlify currently supports Node.js and Go.

In this tutorial we focus on lambda functions written in Node.js.

Netlify gives us a generous free tier limit, with up to 125.000 function invocations and a total of 100 hours of run time every month. Functions have 128MB of memory and each can execute for up to 10 seconds. For normal needs, this is more than enough.

Internally, Netlify runs this function on AWS Lambda, abstracting away all the complexity of AWS for you.

How do we create a function? We upload a JavaScript file in the functions folder of the site.

In this file we must follow a method named handler:

exports.handler = (event, context, callback) => {
  //functionality
}

If you are familiar with AWS Lambda, the function code will be familiar to you. If you’ve never used it, no worries - here’s a brief overview of the parameters our handler receives:

  • event is an object that contains data on the request
  • context contains the user information when using Identity for user authentication
  • callback is a function we can use to create a response

The simplest thing we can do is return a positive response. To do so, we use the callback() method:

exports.handler = (event, context, callback) => {
  callback(null, {
    statusCode: 200,
    body: 'No worries, all is working fine!'
  })
}

Save this to a functions/test.js file.

The only thing you need to do to make it work is to configure the folder for the functions in the netlify.toml file:

[build]
functions = "./functions"

Try this. Create the file in an empty folder, push it to a GitHub repository and create a new Netlify site from that repo.

Once you do so, in the Settings -> Functions menu in Netlify a new menu will show up which shows the details of our functions usage:

The function, which was stored in the functions/test.js file, is accessible at https://YOURSITENAME.netlify.com/.netlify/functions/test.

To access the request parameters, use the event object:

  • event.path the request path
  • event.httpMethod the request HTTP method
  • event.headers the request headers
  • event.queryStringParameters the request query parameters
  • event.body the request body in JSON format

Before we used

callback(null, {
  statusCode: 200,
  body: 'No worries, all is working fine!'
})

to craft a response. You can also add a headers object which contains an associative array (object) with the header values.

This repository by Netlify https://github.com/netlify/netlify-functions-example contains a lot of samples for Netlify Lambda Functions.

Lessons in this unit:

0: Introduction
1: Create a Netlify account
2: Deploy to Netlify
3: A tutorial to host your Static Site on Netlify
4: Auto trigger deploys on Netlify
5: ▶︎ Netlify Lambda Functions Tutorial
6: How to use environment variables in Netlify functions
7: How to use npm packages in Netlify Functions
8: How to access query parameters in Netlify functions
9: How to test Netlify Functions locally
10: How to use Netlify Edge Functions
11: How to set up "cloud cron jobs" using Netlify Scheduled Functions
12: How I fixed the trailing slash in Netlify rewrites
13: Durable cache on Netlify
14: How to return HTML from a Netlify function
15: How to use ES modules in Netlify functions
16: How to trigger a Netlify-Vercel-Cloudflare Pages redeploy using a link