Creating a Back4App app

You can create a new Back4App app using b4a new. It asks you a series of questions and at the end of it, you will have a new Back4app app (with the given name). Additionally, you will also set up a Cloud Code project for the app. You can test that everything works by performing b4a deploy and executing the curl command printed at the end of output.

Let’s do it step by step!

1.We will create a Back4App app or add Cloud Code to an existing app

Open your terminal and type the next command

$ b4a new
Would you like to create a new app, or add Cloud Code to an existing app?
Type "(n)ew" or "(e)xisting": n
Please choose a name for your Parse app.
Note that this name will appear on the Back4App website,
but it does not have to be the same as your mobile app's public name.
Name: CLI-Back4App

2.Creating the directory Name

If you want to give other name to the directory type it,if not,hit ENTER.

Awesome! Now it's time to set up some Cloud Code for the app: "CLI-Back4App",
Next we will create a directory to hold your Cloud Code.
Please enter the name to use for this directory,
or hit ENTER to use "CLI-Back4App" as the directory name.

Now,you have the options to set up a blank project or create a simple Cloud Code project

You can either set up a blank project or create a sample Cloud Code project.
Please type "(b)lank" if you wish to setup a blank project, otherwise press ENTER:<enter>

Successfully configured email for current project to: ${ACCOUNT_EMAIL}

Your Cloud Code has been created at ${CUR_DIR}/app_name

This includes a “Hello world” cloud function, so once you deploy, you can test that it works, with the printed curl command.

3.Let’s deploy the app

Note:Be careful! You have to be on the folder of the app that we want to deploy!

Next, you might want to deploy this code with:

$ b4a deploy
Uploading source files
Uploading recent changes to scripts...
The following files will be uploaded:
/Users/alysson/CLI-Back4app/cloud/main.js
Uploading recent changes to hosting...
The following files will be uploaded:
/Users/alysson/CLI-Back4app/public/index.html
Finished uploading files
New release is named v1 (using Parse JavaScript SDK v2.2.25)

Once deployed you can test that it works by running:

curl -X POST \

-H "X-Parse-Application-Id: ${APPLICATION_ID}" \

-H "X-Parse-REST-API-Key: ${REST_API_KEY}" \

-H "Content-Type: application/json" \ -d '{}' \

https://parseapi.back4app.com/functions/hello

You can see the result os our function

{"result":"Hello world!"}

5.Adding other app to the same folder

We can add an app to the same folder of another created!

To do this,open the terminal and do the b4a add command

$ b4a add
1:back4app
2:myb4app
3:myback4app
Select an app to add to configure:
Written config for "AppChosen"

It was added successfully!