Management API Reference

Build with React Native

Get started with Openfort in your React Native project

1. Install Required Dependencies#

Install the latest version of the Openfort React Native SDK and its required dependencies:

Terminal

_10
# Install Openfort React Native SDK
_10
yarn add @openfort/react-native
_10
_10
# Install required dependencies
_10
yarn add buffer react-native-crypto react-native-get-random-values react-native-randombytes stream-browserify react-native-mmkv

2. Configure Metro#

Create or update your metro.config.js to include the necessary Node.js module shims:


_15
// metro.config.js
_15
const { getDefaultConfig } = require('expo/metro-config');
_15
_15
module.exports = (() => {
_15
const config = getDefaultConfig(__dirname);
_15
_15
// Add shims for Node.js modules
_15
config.resolver.extraNodeModules = {
_15
crypto: require.resolve('react-native-crypto'),
_15
stream: require.resolve('stream-browserify'),
_15
buffer: require.resolve('buffer'),
_15
};
_15
_15
return config;
_15
})();

3. Set up auth providers#

Navigate to the auth providers page on the Openfort dashboard by selecting your project and clicking Auth Providers Methods in the side bar in the players page. Select the account types you'd like users to be able to login with.

4. Get your Openfort keys#

From the Openfort Dashboard, select your desired app and navigate to the developers page. You'll need:

  • Publishable Key: Safe to expose in client-side environment
  • Secret Key: Must be kept secure and used only server-side
  • Shield Keys: Required for non-custodial wallets
    • Create Shield keys in the Shield section
    • Securely store the encryption share shown in the one-time popup
    • You'll get both a Publishable and Secret Shield key

5. Configure your app#

Import Polyfills#

First, import the Openfort React Native polyfills at the top of your app:


_10
import "@openfort/react-native/polyfills";

Set up the WebView#

Add the Openfort Communication WebView to your app's root layout:


_11
// app/_layout.tsx
_11
import { OpenfortCommunicationWebView } from '@openfort/react-native';
_11
_11
export default function RootLayout() {
_11
return (
_11
<>
_11
<OpenfortCommunicationWebView />
_11
<Slot />
_11
</>
_11
);
_11
}

Initialize Openfort#

Configure the Openfort SDK with your keys:


_10
import Openfort from "@openfort/react-native";
_10
_10
const openfort = new Openfort({
_10
baseConfiguration: {
_10
publishableKey: "YOUR_OPENFORT_PUBLISHABLE_KEY",
_10
},
_10
shieldConfiguration: {
_10
shieldPublishableKey: "YOUR_SHIELD_PUBLISHABLE_KEY",
_10
}
_10
});

Important

Because we use mmkv storage, expo-go will not work. Use expo run:ios or expo run:android to run your app.

Next Steps#

Now that you've configured your app, you can use openfort throughout to access the Openfort SDK. Check out our starter repo to see a complete integration.