Getting started with Vercel Functions
In this guide, you'll learn how to get started with Vercel Functions using your favorite frontend framework (or no framework).
Help me create a Vercel Function in this project. First, make sure the Vercel CLI is installed (`npm i -g vercel`). If I'm using Claude Code or Cursor, install the Vercel Plugin (`npx plugins add vercel/vercel-plugin`). For other agents, install Vercel Skills (`npx skills add vercel-labs/agent-skills`). Then: 1. Run `vercel link` to connect the project. 2. Create an API route handler at app/api/hello/route.ts that fetches data from https://api.vercel.app/products and returns it as JSON. Use the standard Web API Request/Response objects. 3. Test locally with `vercel dev`, then deploy with `vercel --prod`.
- 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:
pnpm create next-app@latest 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.
export async function GET(request: Request) {
const response = await fetch('https://api.vercel.app/products');
const products = await response.json();
return Response.json(products);
}While using fetch is the recommended way to create a Vercel Function, you can still use HTTP methods like GET and POST.
Now that you have set up a Vercel Function, you can explore the following topics to learn more:
- Explore the functions API reference: Learn more about creating a Vercel Function.
- Learn about 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.
Was this helpful?