Cloud functions are functions that run in the cloud (server side).

From HBuilderX 3.4, an extended version of cloud functions, cloud objects, has been added.

Developers do not need to purchase or build a server. They only need to write code and deploy it to the cloud to call it on the client (App/Web/Applet, etc.). At the same time, cloud functions can also call each other.

A cloud function is written in the same way as a locally defined JavaScript method, and the code runs in the cloud Node.js. When the cloud function is called by the client, the defined code will be executed in the Node.js runtime environment.

Developers can perform network requests and other operations in cloud functions as in the Node.js environment using JavaScript, or they can use node_modules.

However, DCloud provides uniCloud objects built into cloud functions/cloud objects. Developers use more of the uniCloud api. Not knowing node does not affect development.

Starting from HBuilderX 3.0, right-click in the uniCloud/cloudfunctions directory to create a cloud function, as follows:

Starting from HBuilderX 3.4, the above interface is updated to create a new cloud function/cloud object.

Cloud objects are essentially a kind of encapsulation of cloud functions, and cloud services can be used in an object-oriented way.

Before HBuilderX 3.0, there is no uniCloud directory under the project, directly right-click on the cloudfunctions directory and create a new cloud function

After the cloud function is modified, it can be run locally. Only upload to the cloud to take effect in the cloud.

For more cloud function introductions, refer to Specification.

On This Page