JavaScript

Add Parse SDK to your Javascript Project

Introduction

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

See more about Parse SDK at Parse JavaScript SDK API Reference and Parse open source documentation for JavaScript SDK.

Prerequisites

To complete this tutorial, you will need:

Note: 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.

Step 1 - Installing SDK

The unpkg is a delivery network that makes working with bundled npm modules easier. To install Parse JavaScript SDK, open your index.html file and simply add the following script inside its <head> tag:

index.html

1
<script src="https://unpkg.com/parse/dist/parse.min.js"></script>

Step 2 - Connecting your Parse App

Initialize your Parse app

Use Parse.Initialize method to set up the authentication token, connecting your page with Back4App servers.

Go to your index.html file and inside <script> tag add the following code:

index.html

1
2
Parse.initialize("YOUR_APP_ID", "YOUR_JS_KEY"); //PASTE HERE YOUR Back4App APPLICATION ID AND YOUR JavaScript KEY
Parse.serverURL = "https://parseapi.back4app.com/";

Find your Application ID and your Client Key

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

Step 3 - Testing your conection

Create a test code

Test your initial setup with the following code which creates a new object of the User class.

Add it inside <script> tag, right after Parse.initialize method:

index.html

1
2
3
4
5
6
7
8
9
10
11
12
13
var user = new Parse.User();
user.save({
  username: 'sampeusername',
  email: 'sample@email.com',
  password: '123456'
}, {
  success: function(response) {
    alert('New object create with success! ObjectId: ' + response.id + `, ` + user.get('username'));
  },
  error: function(response, error) {
    alert('Erro: ' + error.message);
  }
});
  1. Open your HTML file in your web browser.
  2. An alert box will show the id of the new User object that was created.
  3. Log in at Back4App.
  4. Find your app and click on Dashboard.
  5. Click on Core.
  6. Go to Browser.
  7. Click on User class.
  8. Check your new object there.

Parse Dashboard - Class User

Next Steps

At this point, you have learned how to get started with JavaScript web apps. You are now ready to explore Parse Server core features and Back4App add-ons.

Learn more by walking around Parse open source documentation for JavaScript SDK.