Vercel Functions
Functions enable running compute on-demand without needing to manage your own infrastructure, provision servers, or upgrade hardware.Functions are available on all plans
Vercel Functions enable server-side code execution on Vercel's Managed Infrastructure, removing the need for server management or resource provisioning. These functions scale automatically with user demand and can interact with APIs, databases, and other resources as part of your project's deployment.
When deployed, Vercel's Framework defined infrastructure, automatically sets up the necessary environment, tools, and patterns as required by your chosen framework. This ensures optimal configuration for your functions, whether they run on the edge for reduced latency or in a specific region.
Vercel Functions can be written with, or without, a framework, and handle tasks such as:
- Streaming data: Process data in real-time, such as chat messages, AI data, or financial transactions
- Authentication: Implement authentication and authorization logic
- Data Processing: Manage intensive tasks, such as image/video manipulation, without impeding client-side performance
The infrastructure and abilities of your Vercel Function is determined by the runtime you choose:
- Node.js runtime (Serverless Functions): Gives you access to all the Node.js APIs that you would expect for writing on the web, with the ability to configure machine resources and dependencies
- Edge runtime (Edge Functions): Opt for this cost-effective choice when you need lightweight JavaScript functions that execute close to the user
To learn more, see choosing a runtime.
To get started with creating your first function, copy the code below:
export const dynamic = 'force-dynamic'; // static by default, unless reading the request
export function GET(request: Request) {
return new Response(`Hello from ${process.env.VERCEL_REGION}`);
}
To learn more, see the quickstart or deploy a template from the options below:
To learn more about the limitations for Vercel Functions, see the Runtimes reference. This highlights common limits such as size, memory, concurrency, payload size limit, duration, and pricing.
For more information on what to do next, we recommend the following articles:
- Functions API Reference: Learn about available APIs when working with Vercel Functions.
- Configuring Functions: Learn how to configure your functions, including the runtime, memory, and region.
- Choose a runtime: Understand the differences between the Node.js and Edge runtimes.
Was this helpful?