How to add Encryption with @realm/react

I am using @realm/react which uses useRealm() a react hook instead of Realm.open

How do I add encryption using Realm when I do not use Realm.open at all?

This is official guide for adding encryption.

@Milkshake encryptionKey is a property of the realm configuration. With @realm/react you can configure this to your realm in two ways:

  • provide it in the configuration given to createRealmProvider
createRealmProvider({schema:[...], encryptionKey:...})
  • add it as a prop to the RealmProvider (this can override specific configuration attributes provided previously in createRealmProvider)
const Root = () => {
  return (<RealmProvider encryptionKey={...}>
    <App/>
  </RealmProvider>)
}
1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.