Start from template
In this section you will learn how to get started with React Native using an Expo template and how to connect it to Back4App in 4 easy steps.
To complete this tutorial, you will need:
- An app created on Back4App.
To get the template project, download and unzip the source code at our GitHub repository into your machine or clone the project with git command line.
Run the following command to download and extract the template using CURL:
OR
Run the following command to clone the template using GIT:
- Make sure that you have installed npm or yarn in your system.
2. On your terminal, run cd react-native-expoto open the project's root directory.
3. Run yarn install to install dependencies.
In this tutorial we are using yarn to manage dependencies but you are free to use npm instead.
To allow the App to securely connect to Back4App servers, you must provide Parse JavaScript SDK with app’s credentials.
- Locate your App Id and Javascript Key credentials navigating to your app Dashboard at Back4App Website > App Settings > Security & Keys.
- On the project’s root directory, open the file at:constants/Keys.js.
The file should look like this:
Copy and paste your App Id and Javascript Key on it.
Inside the App.js of your template project there is a simple function that registers installations of your App to your Back4App Database.
The useEffect hook triggers the createInstalation method once the App is mounted. To run and test your App connection:
- Open your project’s terminal.
- Runyarn android or yarn ios or expo start to open the application on your target platform
- Done, your React Native App must be up and running. Check the result navigating to Back4App Dashboard and clicking on Installation.
To run your App and test your connection, you can also navigate to the project’s directory and run yarn start. This command will compile and enable automatic re-compiles to your app.
At this point, you have learned how to get up and run a React Native application connected to Back4app.