Tutorial
Vercel Functions Quickstart
Build your first Vercel Function in a few steps.Table of Contents
Next.js (/app)
In this quickstart guide, you'll learn how to get started with Vercel Functions using your favorite frontend framework (or no framework).
-
You can use an existing project or create a new one. If you don't have one, you can run the following terminal command to create a Next.js project:
terminalnpx create-next-app@latest --typescript
Open the code block in v0 for a walk through on creating a Vercel Function with the below code, or copy the code into your project. The function fetches data from the Vercel API and returns it as a JSON response.
app/api/hello/route.ts
export function GET(request: Request) {
const response = await fetch('https://api.vercel.app/products');
const products = await response.json();
return Response.json(products);
}
- Functions API Reference: Learn more about creating a Vercel Function.
- Streaming Functions: Learn how to fetch streamable data with Vercel Functions.
- Choosing a Runtime: Learn more about the differences between the Node.js and Edge runtimes.
- Configuring Functions: Learn about the different options for configuring a Vercel Function.
Last updated on July 16, 2024
Was this helpful?