Providers

<JazzReactNativeProvider /> is the core component that connects your React Native application to Jazz. It handles:

  • Data Synchronization: Manages connections to peers and the Jazz cloud
  • Local Storage: Persists data locally between app sessions
  • Schema Types: Provides APIs for the AccountSchema
  • Authentication: Connects your authentication system to Jazz

Setting up the Provider

The provider accepts several configuration options:

No content available for tab:
Tip

Sign up for a free API key at dashboard.jazz.tools for higher limits or production use, or use your email address as a temporary key to get started quickly.

Provider Options

Sync Options

The sync property configures how your application connects to the Jazz network:

import { type SyncConfig } from "jazz-tools";

export const syncConfig: SyncConfig = {
  // Connection to Jazz Cloud or your own sync server
  peer: `wss://cloud.jazz.tools/?key=${apiKey}`,

  // When to sync: "always" (default), "never", or "signedUp"
  when: "always",
};

See Authentication States for more details on how the when property affects synchronization based on authentication state.

Account Schema

The AccountSchema property defines your application's account structure:

No content available for tab:

Additional Options

The provider accepts these additional options:

  • kvStore
    • MMKVStoreAdapter (default)
  • AccountSchema
    • Account (default)
  • CryptoProvider
    • PureJSCrypto (default) - Pure JavaScript crypto provider
    • RNQuickCrypto - C++ accelerated crypto provider

Authentication

The Provider works with various authentication methods, with PassphraseAuth being the easiest way to get started for development and testing. For authentication details, refer to our Authentication Overview guide.

The authentication hooks must always be used inside the Provider component.

Implementing PassphraseAuth is straightforward:

  1. Import the wordlist for generating recovery phrases
  2. Use the usePassphraseAuth hook to handle authentication
  3. Create simple registration and sign-in screens
No content available for tab:

Local Persistence

Jazz for React Native includes built-in local persistence using SQLite. This implementation uses:

  • Database Storage: @op-engineering/op-sqlite - A high-performance SQLite implementation
  • Key-Value Storage: react-native-mmkv - A fast key-value storage system

Local persistence is enabled by default with no additional configuration required. Your data will automatically persist across app restarts.

Quick Crypto

For accelerated crypto operations, you can use the RNQuickCrypto crypto provider.

To use it, install the following Packages:

pnpm add react-native-quick-crypto@1.0.0-beta.18 react-native-nitro-modules react-native-fast-encoder

Then add the following to your provider:

No content available for tab:

For configuration, add the following settings:

# ios/Podfile
ENV['SODIUM_ENABLED'] = '1'

and

// android/gradle.properties
sodiumEnabled=true

Need Help?

If you have questions about configuring the Jazz Provider for your specific use case, join our Discord community for help.