# Cloud Function

A cloud function is a function that runs in the cloud (server side). Physically speaking, a cloud function can be composed of multiple files that occupy a certain amount of computing resources such as CPU memory. Cloud functions are completely independent of each other and can be deployed in various zones. There is no need for developers to purchase or build servers. They only need to write the function code, deploy the code to the cloud, and call the code on the Mini Program side. Meanwhile, the cloud functions can also be called among each other.

A cloud function is written in the same way as a locally defined JavaScript method, and the code runs in Node.js on the cloud. When the cloud function is called by the Mini Program, the defined code is executed in the Node.js runtime environment. A series of operations, e.g. network requests, can be done in the cloud function, just as using JavaScript in the Node.js environment, and we can also use a variety of services via SDK at the backend of cloud function. For example, we can use the database and storage APIs provided in the cloud function SDK for database and storage operations. For details, refer to the backend API documentation of Database and Storage.

The unique advantage of Cloud Base cloud functions is their seamless integration with WeChat login authentication. When a cloud function is called by the Mini Program, the incoming parameters of the cloud function are injected with the openid of the Mini Program user. The developer is not required to verify the openid because it has been authenticated by WeChat and can be used directly.

Next, let's step through the following contents:

点击咨询小助手