React Native
Parse SDK (REST)

Quickstart

16min

Introduction

This guide will help you set up and use Back4App with a new or existing project using the React Native CLI. You’ll install the Parse SDK, initialize it with your app keys, and create your first API call to save and retrieve data from Back4App.

Prerequisites

To complete this tutorial, you will need:

1 - Create your React Native project

There are two main ways to create a React Native project: React Native CLI and Expo. Choose based on your development environment and target platform (iOS or Android)

2 - Install dependencies

In your React Native project, install Parse Javascript SDK and AsyncStorage by running:

npm install parse @react-native-async-storage/async-storage --save
  • Parse Javascript SDK - To integrate your App with Back4app servers.
  • React Native Async Storage - To use Parse SDK, an AsyncStorage handler is required.

For iOS, also add native AsyncStorage support:

cd ios & pod install

3 - Get your App Keys

After creating your app on Back4App, find your App Keys under App Settings > Security & Keys. You’ll need both the Application ID and JavaScript KEY to connect.

Document image


4 - Initialize Parse and connect to Back4App

Open index.tsx and initialize Parse with your Application ID and JavaScript KEY:

index.tsx


5 - Save and Retrieve Data

With Parse initialized, create two functions in index.tsx to save and fetch data from Back4App.

TypeScript


6 - Test your App

  1. Open your project’s terminal.
  2. Run the project.

Run npx react-native run-android or npx react-native run-ios to open the application on your target platform.

Run expo start, and follow the instructions to view the app in your browser or device.

Document image


Troubleshooting

Some common issues and solutions:

Metro has encountered an error: while trying to resolve module “idb-keyval’ from file

Solution: Go to the metro.conf.js file and change it to this one:

JS


Unable to resolve module ‘EventEmitter’

Solution: Go to the file: node_modules\parse\lib\react-native\EventEmitter.js and change this row:

var EventEmitter = require('../../../react-native/Libraries/vendor/emitter/EventEmitter');

to this:

import EventEmitter from 'react-native/Libraries/vendor/emitter/EventEmitter';

In the same file EventEmitter.js, change the following row:

module.exports = EventEmitter;

to this:

export default EventEmitter;

Issues with babel

In case you face any issues with babel, consider updating your babel.config.js to the following:

module.exports = function (api) { api.cache(true); return { presets: ['babel-preset-expo'], plugins: [ '@babel/plugin-proposal-export-namespace-from', 'react-native-reanimated/plugin', ], }; };

Next Steps

This guide covers the basic setup and data storage with Back4App. Explore Parse features, including data storage, real-time capabilities, local data storage, cloud functions, authentication, and file storage.