Skip to main content
Version: v3

Getting Started with Cloud Functions and Hooks

Cloud Functions lets you run backend code on the cloud in response to various types of events. It is supported by our client-side SDKs and can automatically serialize objects that have the data types provided by our Data Storage service.

The following scenarios can be easily implemented with the help of Cloud Functions and Hooks:

  • Manage complex logics in one place without implementing them with different languages for each platform.
  • Adjust certain logics of your project on the server side without updating clients.
  • Retrieve and update data regardless of the ACL or class permissions.
  • Trigger custom logics or perform additional permission checks when objects are created, updated, or deleted, or when users are logged in or verified.
  • Run scheduled tasks to fulfill requirements like closing unpaid orders every hour, deleting outdated data every midnight, etc.

You can write Cloud Functions with any of the languages (runtime environments) supported by Cloud Engine, including Node.js, Python, Java, PHP, .NET, and Go. Our dashboard provides an online editor for you to write Cloud Functions in Node.js. If you prefer using another language, please create a project based on our demo project and deploy it to Cloud Engine.

info

If you only need to write simple Cloud Functions and Hooks with Node.js, see Cloud Functions and Hooks Guide § Writing Cloud Functions Online.

Write a Cloud Function

You can find the following Cloud Function example in the demo project of the respective runtime environment:

cloud.js
AV.Cloud.define("hello", function (request) {
return "Hello world!";
});

The way you write a Hook is similar to that for a Cloud Function. We will cover more about the usage of Cloud Functions and Hooks later.

Next Steps

Read Cloud Functions and Hooks Guide to learn how you can get the most out of Cloud Functions. If you’re interested in more advanced ways of using the Cloud Engine SDK, you can jump to Cloud Engine SDK Guide. If you haven’t read it yet, make sure to check out Cloud Engine Platform Features where you can explore the diverse features provided by Cloud Engine. To learn more about the specific runtime environments provided by Cloud Engine, see the pages below: