Overview
Pages Functions is a Serverless function service provided by EdgeOne Pages. It allows you to write and deploy server-side code in the project without configuration or managing servers. The platform automatically scales based on request volume to help you quickly build full-stack applications.
Currently available two types of Functions:
Edge Functions: Runs on EdgeOne global edge nodes, provides ultra-low latency and millisecond-level cold startup, suitable for high-concurrency, latency-sensitive lightweight services.
Cloud Functions: Deployed on cloud servers, supports Node.js, Python, and Go multiple runtime environments, possesses longer running time and stronger computing power, suitable for complex business logic and data processing.
Getting Started
Under the directory ./edge-functions/api of your project, use the following example code to create your first Edge Function:
export default function onRequest(context) {return new Response('Hello from Edge Functions!');}
Under the directory ./cloud-functions/api of the project, use the following example code to create your first Cloud Function:
export default function onRequest(context) {return new Response('Hello from Cloud Functions!');}
Difference Between Edge Functions and Cloud Functions
Features | Edge Functions | Cloud Functions |
Running location | global edge node | cloud server |
cold start time | millisecond-level | Hundred-millisecond level |
Latency performance | extremely low | Moderately Low |
runtime environment | Edge Runtime | Node.js / Python / Go |
Scenarios | High-concurrency, latency-sensitive, short execution time | Complex data processing, extended execution time |
Function Debugging
1. Install EdgeOne CLI:
npm install -g edgeone2. Local development: Execute
edgeone pages dev under the Pages code project to start local service and perform function debugging.3. Function release: Push code to the remote repository for auto-build and function release.
Note:
When debugging Cloud Functions locally, ensure the corresponding runtime environment (Node.js/Python/Go) is installed.
Log Analysis
The Pages console provides basic log viewing functionality. Developers can view basic log information for function calls, quickly detect and resolve anomalies or errors in API calls through logs. For detailed directions, view the document Log Analysis.
