Backends
EdgeOne Pages supports various popular backend frameworks to optimize your backend development and operation experience. We offer high-quality support for mainstream backend frameworks, and in many cases, you do not need any initial configuration to complete the deployment.
To help you get started faster, we provide some ready-made templates. You can create a project with one-click deployment to build your applications.
Next, we will show the basic configuration of each framework to help you quickly deploy on Pages.
Express.js
Express.js is a Node.js-based Web application framework with a set of powerful features to build single-page, multi-page, and hybrid Web applications. It is known for its flexibility and minimalistic feature, allowing developers to select components based on project requirements.
Note:
The built-in route of the Express framework is mounted to the configured routing of node-functions by default, and the entry function file name must be in the format [[]], such as [[default]].js.
Refer to the following example to quickly create an Express.js app:
// ./node-functions/express/[[default]].jsimport express from "express";const app = express();app.use((req, res, next) => {console.log(`[Log] ${req.method} ${req.url}`);next();});app.get("/", (req, res) => {res.json({ message: "Hello from Express on Node Functions!" });});export default app;
Ensure all dependencies are installed before deployment, and use
edgeone pages dev to develop locally and test.
Koa.js
Koa.js is a next-generation Node.js Web framework developed by the Express team. It leverages async/await grammar and middleware to handle asynchronous operations in a more elegant way, thereby achieving simpler and more expressive code. Koa.js is more lightweight, with no middleware bundled, providing larger freedom.
Note:
The built-in route of the Koa framework is mounted to the configured routing of node-functions by default, and the entry function file name must be in the format [[]], such as [[default]].js.
Refer to the following example to quickly create a Koa.js app:
// ./node-functions/koa/[[default]].jsimport Koa from 'koa';import Router from '@koa/router';const app = new Koa();const router = new Router();app.use(async (ctx, next) => {const start = Date.now();await next();const ms = Date.now() - start;ctx.set('X-Response-Time', `${ms}ms`);});router.get('/', async (ctx) => {ctx.body = { message: 'Hello from Koa on Node Functions!' };});app.use(router.routes());app.use(router.allowedMethods());export default app;
Koa.js is suitable for backend services that require high customization and performance. Before deployment, please ensure all dependencies are installed and use
edgeone pages dev to develop locally and test.