diff --git a/packages/realm/src/platform/react-native/binding.ts b/packages/realm/src/platform/react-native/binding.ts index e5199590af..7f1c779e3c 100644 --- a/packages/realm/src/platform/react-native/binding.ts +++ b/packages/realm/src/platform/react-native/binding.ts @@ -21,6 +21,7 @@ declare const global: Record; import { NativeModules } from "react-native"; import { NativeBigInt, PolyfilledBigInt, type binding, injectNativeModule } from "../binding"; import { assert } from "../../assert"; +import { RealmInExpoGoError, isExpoGo } from "./expo-go-detection"; try { const RealmNativeModule = NativeModules.Realm; @@ -46,7 +47,11 @@ try { }, }); } catch (err) { - throw new Error( - "Could not find the Realm binary. Please consult our troubleshooting guide: https://www.mongodb.com/docs/realm-sdks/js/latest/#md:troubleshooting-missing-binary", - ); + if (isExpoGo()) { + throw new RealmInExpoGoError(); + } else { + throw new Error( + "Could not find the Realm binary. Please consult our troubleshooting guide: https://www.mongodb.com/docs/realm-sdks/js/latest/#md:troubleshooting-missing-binary", + ); + } } diff --git a/packages/realm/src/platform/react-native/expo-go-detection.ts b/packages/realm/src/platform/react-native/expo-go-detection.ts index 82612cd97c..3ec004742f 100644 --- a/packages/realm/src/platform/react-native/expo-go-detection.ts +++ b/packages/realm/src/platform/react-native/expo-go-detection.ts @@ -35,7 +35,3 @@ export class RealmInExpoGoError extends Error { ); } } - -if (isExpoGo()) { - throw new RealmInExpoGoError(); -}