How to access query parameters in Netlify functions
On this page
Why query parameters are useful in Netlify Functions#
Query parameters are one of the simplest ways to pass data to a backend endpoint. You have probably used them many times without thinking about it.
For example, a URL like this:
/api/signup?email=test@example.com
contains extra information that the server can read and act on.
When you build Netlify Functions, accessing query parameters is very common. You might use them for filtering data, passing IDs, or handling small actions without needing a full request body.
Where query parameters live in Netlify Functions#
In Netlify Functions, all request data is passed into the handler function as an event object.
Query parameters are available on:
event.queryStringParametersThis object contains all query values from the URL.
Basic example in TypeScript#
Here is a simple Netlify Function written in TypeScript that reads a query parameter called email:
import { Handler } from "@netlify/functions"
export const handler: Handler = async (event) => {
const email = event.queryStringParameters?.email
return {
statusCode: 200,
body: JSON.stringify({
receivedEmail: email ?? "no email provided"
})
}
}If you call this function using a URL like:
https://your-site.netlify.app/.netlify/functions/example?email=test@example.com
The function will receive test@example.com as the value of email.
Handling missing query parameters safely#
Query parameters are optional by nature. A user can easily call your function without them.
That is why it is important to handle missing values gracefully.
Using optional chaining (?.) helps avoid runtime errors:
const email = event.queryStringParameters?.emailYou can then decide what to do if the value is missing, such as returning an error or a default response.
Working with multiple query parameters#
If your URL contains more than one query parameter, they all show up in the same object.
For example:
/api/search?term=netlify&page=2
You can read them like this:
const term = event.queryStringParameters?.term
const page = event.queryStringParameters?.pageEach value is a string, so remember to convert it if you need a number or boolean.
When to use query parameters in Netlify#
Query parameters work best for:
- Simple filters
- Optional values
- Small bits of data
- GET requests
For larger or sensitive data, a POST request with a request body is usually a better choice.
Quick reference#
- Query parameters live on event.queryStringParameters
- Each value is a string
- Always handle missing values safely
- Use TypeScript for better clarity and safety

Written by
Developer Advocate at RevenueCat and creator of Netli.fyi. Building on Netlify since 2019 and writing from hands-on experience deploying dozens of production sites.
More about the author