The powerful Command Line Tool you’ve been using on Parse.com is now available at Back4App. You can continue to interact with your Parse Server using the Terminal. The Back4App CLI(command line interface) can be used to perform various actions on your Parse App like to create a new app, develop and deploy cloud code, manage app releases, set the SDK version, etc.
Let’s see an example of how simple is creating an App using CLI.
At this example we will create a new empty app on Back4App with a simple cloud function: hello that return: Hello World.
You can create a new Back4App app using the command: 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 and executing: b4a deploy curl command printed at the end of the output.
1.Install your Back4App CLI
MACOS and Linux
In Mac OS X and Linux/Unix environments, you can get the Back4App Command Line Tool by running this command:
This installs a tool named “b4a” to class=/usr/local/bin/b4a. There’s no other junk, so to uninstall, just delete that file. This will also update your command line tool if you already have it installed.
Windows
The Back4App command line interface for Windows is available at Github Repository.
Please download the b4a.exe file.
Now, we are going to manually install the downloaded program
Open the folder where b4a.exe file is;
Copy the file b4a.exe;
Paste the file on C:\windows\system32 path.
NOTE: b4a.exe is not an installer, it is just a plain Windows executable.
2.Connect your Back4App account to CLI
Account Keys are personal access tokens that can be used to create a new Back4App app and list properties and keys for the given Back4App app. You can configure the command line interface to use account keys to perform various actions like creating a new app and fetching master key for an app when required (for instance, when performing deploy, fetching logs, etc.).
After logged at Back4App go to your account menu and click over Account Keys:
Write your key name (1), add this to your key list (2) and then save the key (3).
You have a new Key!
Now, go to your terminal and type b4a configure account key. Enter your key and press enter.
$ b4a configure accountkey
Input your account key or press ENTER to generate a new one.
NOTE: on pressing ENTER we'll try to open the url:
"https://www.parse.com/account/keys"
in default browser.
Account Key: Vh5c3kRbzUmuLrVrOkvMkio989MmXUVoIeIbjTUC
Note: this operation will overwrite the account key:
"************************************jTUC"
for email: "[email protected]"
Successfully stored account key for: "[email protected]".
$
3.Create a new Back4App App or connect your existing App
3.1.Create a new Back4App App
Open your terminal and type the next command: b4a new. Then choose if you want to create a new app or connect to an existing app (n). Choose a name to your App and press enter. See the commands printed on your terminal bellow:
$ 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
Now we are going to add cloud code to your App. Choose a Directory name to store locally your Code or press ENTER to use your app name as your directory name.
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.<enter>
3.2.Connect an existing App
$ b4a new
Would you like to create a new app, or add Cloud Code to an existing app?
Type "(n)ew" or "(e)xisting": e
1: Live Query
2: MyApp2
Select an App to add to config: 2
Please enter the name of the folder where we can download the latest deployed
Cloud Code for your app "MyApp2"
4.Create your Cloud directory and add Cloud Code
Now you can create a blank cloud code or press enter to create a standard cloud function: Hello World!
Directory Name:
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: "[email protected]"
Your Cloud Code has been created at /Users/alysson/CLI-Back4App.
This includes a "Hello world" cloud function, so once you deploy,
you can test that it works, with the printed curl command.
Next, you might want to deploy this code with:
cd /Users/alysson/CLI-Back4App
b4a deploy
Once deployed you can test that it works by running:
curl -X POST \
-H "X-Parse-Application-Id: 1mbEzX6hH4OBX3lq6QPnJfhOfdSAN6sVte2gzCbv" \
-H "X-Parse-REST-API-Key: 5EEeLGwkK9SD3d9zJfbtcHXXc4l670Fcu3U6POrI" \
-H "Content-Type: application/json" \
-d "{}" \
https://parseapi.back4app.com/functions/hello
5.Deploy your Cloud Code
Navigate to your cloud code folder and deploy your code using the command: b4a deploy.
$ 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)
Check your function at Back4App. Go to your app > features > Cloud Code > Server:
NOTE: You can use this command to upload all your cloud code files. You just need to transfer those files to your linked directory and use the b4a deploy command.
5.Test your function
Use the given command to run a request on Back4App API and call your hello function:
– Install your Back4App CLI – Connect your Back4App account to CLI – Create a new Back4App App or connect your existing App – Create your Cloud directory and add Cloud Code – Test your function
Alysson Melo
As a computer engineer and Back4App co-founder, I specialize in simplifying the application development process for developers worldwide. With a background in software engineering, product management, machine learning, business strategy, my career spans over a decade of launching innovative products and also helping other entrepreneurs.
More details are available on this LinkedIn profile .