React Native Installation and Setup

This guide covers setting up Jazz for React Native applications from scratch. If you're using Expo, please refer to the React Native - Expo guide instead. If you just want to get started quickly, you can use our React Native Chat Demo as a starting point.

Jazz supports the New Architecture for React Native.

Tested with:

"react-native": "0.79.2",
"react": "18.3.1"

Installation

Create a new project

(Skip this step if you already have one)

npx @react-native-community/cli init myjazzapp
cd myjazzapp

If you intend to build for iOS, you can accept the invitation to install CocoaPods. If you decline, or you get an error, you can install it with pod-install.

Install dependencies

# React Native dependencies
npm install @react-native-community/netinfo @bam.tech/react-native-image-resizer

# React Native polyfills
npm install @azure/core-asynciterator-polyfill react-native-url-polyfill readable-stream react-native-get-random-values @op-engineering/op-sqlite react-native-mmkv react-native-fast-encoder

# Jazz dependencies
npm install jazz-tools cojson-core-rn

cojson-core-rn is our high-performance crypto provider for React Native. And it is required for React Native applications.

Note

In the React Native ecosystem, the Autolinking process (which links native code from libraries to your iOS and Android projects) relies on scanning the dependencies listed in your application's root package.json. As a result, cojson-core-rn must be a direct dependency of the app, and not a dependency of a dependency.

You must keep the versions of the two packages (jazz-tools and cojson-core-rn) the same.

"dependencies": {
  "cojson-core-rn": "x.x.x", # same version as jazz-tools
  "jazz-tools": "x.x.x" # same version as cojson-core-rn
}
Versioning

While you can distribute your own JS code changes OTA, if you update your Jazz version, this will result in changes in the native dependencies, which cannot be distributed over the air and requires a new store submission.

Add polyfills

Jazz provides a quick way for you to apply the polyfills in your project. Import them in your root index.js file:

import { AppRegistry } from 'react-native';
import App from './App';
import { name as appName } from './app.json';
import 'jazz-tools/react-native/polyfills';

AppRegistry.registerComponent(appName, () => App);

Authentication

Jazz provides authentication to help users access their data across multiple devices. For details on implementing authentication, check our Authentication Overview guide and see the React Native Chat Demo for a complete example.

Next Steps

Now that you've set up your React Native project for Jazz, you'll need to:

  1. Set up the Jazz Provider - Configure how your app connects to Jazz
  2. Add authentication (optional) - Enable users to access data across devices
  3. Define your schema - See the schema docs for more information
  4. Run your app:
# Start Metro
npm run start

# In a new terminal tab:
npm run ios
# or
npm run android

If all goes well, your app should start up without any angry red error screens. Take a quick look at the Metro console too - no Jazz-related errors there means you're all set! If you see your app's UI come up smoothly, you've nailed the installation.

If you run into any issues that aren't covered in the Common Issues section, drop by our Discord for help.

Common Issues

  • Metro bundler errors: If you see errors about missing polyfills, ensure you installed them all and are importing them correctly
  • iOS build failures: Make sure you've run pod install after adding the dependencies.
  • Android build failures: Ensure your Android SDK and NDK versions are compatible with the native modules.

Install CocoaPods

If you're compiling for iOS, you'll need to install CocoaPods for your project. If you need to install it, we recommend using pod-install:

npx pod-install
Was this page helpful?