{"record":{"id":"bb1428cbd8acb3ea","repo":"tursodatabase/turso","slug":"tursodatabase-sync-react-native-native-module-no","errorCode":null,"errorMessage":"@tursodatabase/sync-react-native: Native module not found. Make sure you have properly linked the library.\n- iOS: Run 'pod install' in your ios directory\n- Android: Make sure the package is properly included in your MainApplication.java","messagePattern":"@tursodatabase/sync-react-native: Native module not found\\. Make sure you have properly linked the library\\.\n- iOS: Run 'pod install' in your ios directory\n- Android: Make sure the package is properly included in your MainApplication\\.java","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"bindings/react-native/src/index.ts","lineNumber":54,"sourceCode":"\n  // Enums\n  TursoStatus,\n  TursoType,\n} from './types';\n\n// Re-export classes\nexport { Database } from './Database';\nexport { Statement } from './Statement';\n\n// Export file system configuration function\nexport { setFileSystemImpl } from './internal/ioProcessor';\n\n// Get the native module\nconst TursoNative: TursoNativeModule | undefined = NativeModules.Turso;\n\n// Check if native module is available\nif (!TursoNative) {\n  throw new Error(\n    `@tursodatabase/sync-react-native: Native module not found. Make sure you have properly linked the library.\\n` +\n    `- iOS: Run 'pod install' in your ios directory\\n` +\n    `- Android: Make sure the package is properly included in your MainApplication.java`\n  );\n}\n\n// Install the JSI bindings\nconst installed = TursoNative.install();\nif (!installed) {\n  throw new Error(\n    '@tursodatabase/sync-react-native: Failed to install JSI bindings. Make sure the New Architecture is enabled.'\n  );\n}\n\n// Get the proxy that was installed on the global object\n// __TursoProxy is declared globally in types.ts\nconst TursoProxy: TursoProxyType = __TursoProxy;\n","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/tursodatabase/turso/blob/244cde92a7df7f9b8b8b7a4075c35a12977e303e/bindings/react-native/src/index.ts#L36-L72","documentation":"The package's module-init code reads NativeModules.Turso and throws immediately at import time if it is undefined. This means React Native autolinking never registered the native Turso module in the app binary, so there is nothing for the JS side to talk to. It is a build/linking problem, not a runtime logic error.","triggerScenarios":"Any import of '@tursodatabase/sync-react-native' in an app where the native module is absent: iOS without pod install, an Expo Go session (Expo Go cannot load third-party native modules), an Android build where the package is missing from MainApplication/getPackages, or a non-RN runtime (web, Node, Jest) that resolves the RN entry anyway.","commonSituations":"Fresh clone where a teammate forgot pod install; using Expo Go instead of a dev build or eas build; upgrading RN or switching to Expo modules autolinking silently dropping the package; Jest unit tests importing app code that transitively loads the SDK.","solutions":["iOS: run cd ios && pod install, then do a full rebuild (xcodebuild / run from Xcode) - a Metro reload is not enough","Expo: switch to a development build (npx expo prebuild, npx expo run:ios / eas build) - the module cannot load inside Expo Go","Android: verify the package appears in the autolinked packages list (npx react-native config) and rebuild; for manual linking, ensure the package is registered in MainApplication","In Jest, map '@tursodatabase/sync-react-native' to a mock in moduleNameMapper so the import-time check never runs","On web/Node targets, import the web/serverless entry instead of the react-native one"],"exampleFix":"// jest.config.js - before: tests crash at import with 'Native module not found'\n// after: mock the native module in the Jest environment\nmodule.exports = {\n  moduleNameMapper: {\n    '^@tursodatabase/sync-react-native$': '<rootDir>/__mocks__/turso-rn.ts',\n  },\n};","handlingStrategy":"validation","validationCode":"// Probe before importing the SDK (e.g. in Jest, web, or mixed-platform code)\nimport { NativeModules, Platform } from 'react-native';\nconst nativeReady = Platform.OS === 'ios' || Platform.OS === 'android'\n  ? !!NativeModules.Turso\n  : false;\nif (!nativeReady) {\n  throw new Error('Turso native module unavailable on this platform - use the web/serverless build or a dev build');\n}\nconst { connect } = await import('@tursodatabase/sync-react-native');","typeGuard":"function hasTursoNative(mods: Record<string, unknown>): boolean {\n  return typeof mods.Turso === 'object' && mods.Turso !== null;\n}","tryCatchPattern":"Because the throw happens at module import time, wrap a dynamic import: try { turso = await import('@tursodatabase/sync-react-native'); } catch (e) { if (String(e.message).includes('Native module not found')) { /* fall back to web build / skip feature */ } else throw e; }","preventionTips":["Always run pod install and a full rebuild after adding or upgrading the SDK","Use Expo dev builds or eas build - the module cannot load in Expo Go","Mock the package in Jest via moduleNameMapper so unit tests never execute the import-time check","Add a CI step that fails the build if npx react-native config does not list the Turso dependency"],"tags":["react-native","native-module","autolinking","expo","setup","import-time"],"backgroundTag":"rn-native-module-missing","analyzedSha":"244cde92a7df7f9b8b8b7a4075c35a12977e303e","analyzedAt":"2026-08-20T07:02:18.389Z","contentChangedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}