JavaScript

Install Parse SDK

12min

Install Parse SDK to your JavaScript Project

Introduction

In this section, you learn how to install Parse JavaScript SDK into your HTML project.

Prerequisites

To complete this tutorial, you will need:

Parse JavaScript SDK supports Firefox 23+, Chrome 17+, Safari 5+, and IE 10.

IE 9 is supported only for apps that are hosted with HTTPS.

1 - Install SDK

To enable the Parse JavaScript SDK in your web app, create a new index.html file or use your main HTML file and add the following script inside its <head> tag:

index.html
ο»Ώ

2 - Connect your Parse App

Initialize your Parse app

Before using any Parse functionality, you need to call the Parse.Initialize method to set up the authentication token and connect your page with Back4App servers.

In your index.html file, create a <script> tag at the bottom of it and add the following code:

index.html
ο»Ώ

Note that creating and importing a separate JavaScript file is strongly advised instead of using inline JS code in your HTML file, but for simplicity, we will use the latter here.

Find your Application ID and your Client Key

  1. Go to your App Dashboard at the Back4App website.
  2. Navigate to app settings: Click on Server Settings > Core Settings block> Settings.
  3. Return to your Parse.Initialize function and paste your applicationId and javaScriptKey there.

3 - Testing your connection

Create a test code

Test your initial setup with the following code which creates a new object of the User class. Add it inside the <script> tag, right after the Parse.initialize method:

index.html
ο»Ώ

You also need to create the input fields to pass data to your JavaScript function, so add these plain elements to your <body> section of your HTML file:

index.html
ο»Ώ

Go ahead and test this example app following these steps:

  1. Open your HTML file in your web browser.
  2. Fill the input fields with data and click;
  3. An alert box will show the id of the new User object that was created.
  4. Login at Back4App.
  5. Find your app and click on Dashboard.
  6. Click on Core.
  7. Go to Browser.
  8. Click on User class.
  9. Check your new object there.

After these steps you should see something like this:

Document image
ο»Ώ

Here is the full app code:

index.html
ο»Ώ

It’s done!

At this point, you have learned how to get started with JavaScript web apps.

ο»Ώ