{"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/bad083fafbefdeae9a42ec19bdaaad8918dcf411/bindings/react-native/src/index.ts#L36-L72","documentation":"This package installs JSI bindings at import time: it reads NativeModules.Turso and throws immediately if it is undefined, meaning React Native autolinking/manual linking never registered the native module. Because it is a module-scope throw, any import of '@tursodatabase/sync-react-native' fails the whole JS bundle, not just a call.","triggerScenarios":"iOS without pod install after adding the package; Android where the package is not registered in MainApplication (old-architecture manual linking); running inside Expo Go, which has no third-party native code; importing the package in Jest or Node (no native runtime at all); autolinking broken by a custom react-native.config.js.","commonSituations":"Fresh clone where a teammate committed package.json but pods/gradle were never refreshed; switching from a dev build to Expo Go for quick testing; Jest unit tests importing a module that transitively pulls in the SDK; monorepo where the app does not autolink libraries from nested node_modules.","solutions":["iOS: run cd ios && pod install, then rebuild the app fully","Android: run a clean build (./gradlew clean) so autolinking regenerates; verify the package resolves in react-native.config.js","Expo: use a development build (npx expo run:ios / run:android), never Expo Go","Jest: add a setupFiles mock (jest.mock('react-native', () => ({ NativeModules: { Turso: { install: () => true } } }))) or mock the SDK module","Reset Metro cache: npx react-native start --reset-cache"],"exampleFix":"// jest.setup.js (before)\n// importing the SDK in tests throws: Native module not found\n\n// jest.setup.js (after)\njest.mock('react-native', () => ({\n  NativeModules: { Turso: { install: () => true } },\n}));\n// jest.config.js: setupFiles: ['<rootDir>/jest.setup.js']","handlingStrategy":"validation","validationCode":"// Check availability BEFORE importing the SDK (it throws at import time)\nimport { NativeModules, Platform } from 'react-native';\n\nconst nativeAvailable =\n  (Platform.OS === 'ios' || Platform.OS === 'android') &&\n  !!NativeModules.Turso;\n\nlet db: typeof import('@tursodatabase/sync-react-native');\nif (nativeAvailable) {\n  db = require('@tursodatabase/sync-react-native');\n}","typeGuard":"function isTursoNativeAvailable(): boolean {\n  try {\n    const { NativeModules } = require('react-native');\n    return typeof NativeModules.Turso?.install === 'function';\n  } catch {\n    return false;\n  }\n}","tryCatchPattern":"let sdk: typeof import('@tursodatabase/sync-react-native');\ntry {\n  sdk = require('@tursodatabase/sync-react-native');\n} catch (e) {\n  if (String((e as Error).message).includes('Native module not found')) {\n    throw new Error('Run pod install / rebuild, or use an Expo dev build instead of Expo Go');\n  }\n  throw e;\n}","preventionTips":["After adding/upgrading the package always run pod install and rebuild native","Never import the SDK in Jest/Node without a NativeModules mock in setupFiles","Use an Expo development build, not Expo Go","Keep a CI smoke test that imports the SDK on-device to catch linking regressions early"],"tags":["react-native","native-module","linking","expo","jest"],"backgroundTag":"native-module-missing","analyzedSha":"bad083fafbefdeae9a42ec19bdaaad8918dcf411","analyzedAt":"2026-08-16T23:12:11.798Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}