Cloud Code functions
Cloud Code is a powerful tool that enables you to execute JavaScript functions directly on the server, adding advanced features to your application without the need to manage your own servers. Running in Back4app’s environment ensures scalability and simplicity.
With Cloud Code, you can:
- Automate database actions in response to events.
- Create custom validations for requests.
- Integrate your application with external services using npm libraries.
To complete this tutorial, you will need an app created at Back4app. Follow the Create a new App tutorial to learn how to create an app at Back4app.
- To deploy and execute a cloud function from your App
Go to the Cloud Code section in your Back4app dashboard. You’ll find two main folders: cloud and public.

The main.js file is where your Cloud Code functions are defined.
If needed, you can import functions from other files using:
Some basic function examples include:
- A simple greeting function:
- A function to sum two numbers:
Once your functions are ready, click the Deploy button to publish them to the Back4app environment.
You can test your functions directly via the API using tools like cURL or any preferred SDK. Below is an example for calling the hello function:
- Data Manipulation: Create, edit, or retrieve objects in your database with specific functions, such as this example for creating a ToDo item:
- Advanced Queries: Retrieve information directly from the database:
With Cloud Code, you can effortlessly build robust and customized solutions. It’s ideal for automation, integrations, and validations and works seamlessly with any technology, such as Flutter, React Native, or REST API.
If you encounter any issues, the Back4app support team is available to assist you.