# How to use `create-react-native-app` with GraphQL & Apollo URL: https://www.prisma.io/blog/tutorial-using-create-react-native-app-with-graphql-apollo-e630aee3ae1e Published: 2017-03-28 Authors: Nikolas Burk Description: Learn how to build an Instagram-style React Native app with Create React Native App, GraphQL, and Apollo. The easiest way to get started with React Native apps that are using a GraphQL backend is with create-react-native-app and Apollo. In this tutorial we will learn how to build an Instagram app, where users can view and post images. > ⚠️ **This tutorial is outdated!** Check out the [Prisma examples](https://github.com/prisma/prisma-examples/) to learn how to build GraphQL servers with a database. ⚠️ The easiest way to get started with React Native apps that are using a GraphQL backend is with [`create-react-native-app`](https://github.com/react-community/create-react-native-app) and [Apollo](http://dev.apollodata.com/). In this tutorial we will learn how to build an Instagram app, where users can view and post images. The complete code for this tutorial is available on [GitHub](https://github.com/graphcool-examples/react-native-graphql/tree/master/quickstart-with-apollo). > If you’re just getting started with GraphQL, check out the [How to GraphQL](https://www.howtographql.com) fullstack tutorial website for a holistic and in-depth learning experience. ## Getting your GraphQL endpoint [#getting-your-graphql-endpoint] For this tutorial you’ll need a GraphQL project with the following data model: ```graphql type Post { id: ID! description: String! imageUrl: String! } ``` Using the [Graphcool CLI](https://www.npmjs.com/package/graphcool), you can generate a fully-fledged GraphQL server from your command line by providing this schema as an input argument to the `graphcool init` command: 1. In case you haven’t already, install the Graphcool CLI: `npm install -g graphcool` 2. Save the schema from above in a file called `instagram.schema` 3. Create the GraphQL server: `graphcool init instagram.schema` > **Note**: This tutorial uses Graphcool to bootstrap a GraphQL server. If you want to build your own GraphQL server to be used in production use cases, be sure to check out [Prisma](https://www.prisma.io/) That’s it, copy the endpoint for the Simple API since we'll need it later on. Notice that you can now also manage this project in the Graphcool console or explore it in a GraphQL playground. ## Getting started with `create-react-native-app` [#getting-started-with-create-react-native-app] ### Installation [#installation] With `create-react-native-app`, it's super easy to start out with a new React Native application! It comes with a lot of nice features and configurations out-of-the-box, let's you easily run your app on a real-device by scanning a QR code from the terminal and saves you from having to use native development tools such as Xcode or Android Studio. If you don’t have `create-react-native-app` installed on your machine yet, now is the time to do so with the following command: npm install -g create-react-native-app ### Creating a new React Native app [#creating-a-new-react-native-app] After installing, we can easily create and run a new project from the command line: create-react-native-app react-native-apollo-instagram-example cd react-native-apollo-instagram-example npm run ios # or npm run android Here is what the initial screen looks like in the iOS simulator: ![](https://www.prisma.io/blog/tutorial-using-create-react-native-app-with-graphql-apollo-e630aee3ae1e/imgs/0-A9dtztGpco-x9gTF.png) Hot-reloading is already setup as well, so any changes you make in the JavaScript code will immediately appear on the screen! ## Integrating Apollo in a React Native Application [#integrating-apollo-in-a-react-native-application] ### Installing the Dependencies [#installing-the-dependencies] [Apollo Client](http://dev.apollodata.com/react/) is one of the most popular GraphQL clients available at the moment. It implements features like caching, optimistic UI, [query batching](https://www.prisma.io/blog/improving-performance-with-apollo-query-batching-66455ea9d8b) as well as realtime updates using subscriptions and generally makes interacting with a GraphQL backend a breeze. We will need three dependencies to use it in our React application: 1. [`apollo-client`](https://github.com/apollographql/apollo-client): Contains the general functionality of Apollo Client 2. [`react-apollo`](https://github.com/apollographql/react-apollo): Implements React-specific bindings for Apollo 3. [`graphql-tag`](https://github.com/apollographql/graphql-tag): Provides functionality for parsing the [JavaScript template literals](http://exploringjs.com/es6/ch_template-literals.html) that will contain our GraphQL queries and mutations You can install all three dependencies at once: npm install apollo-client react-apollo graphql-tag --save Additionally, we’re using [React Router Native](https://github.com/jmurzy/react-router-native) to deal with navigation in our app, let’s go ahead install that as well: npm install react-router-native --save ### Mocking the needed Components [#mocking-the-needed-components] Let’s first build the components needed for our app, where we want to display, create or delete posts. Afterwards, we’ll inject the required data using Apollo and wire everything up with React Router. These are the three components that we need: * `ListPage` in `components/ListPage.js` that will list all posts from our backend ```js import React from 'react' import { ScrollView, View, Text, Button } from 'react-native' import { withRouter } from 'react-router-native' class ListPage extends React.Component { render() { return ( // here is where we will render our posts