{"record":{"id":"3146c7cfaa98c619","repo":"tursodatabase/turso","slug":"unable-to-get-database-path-for-this-platform-mak","errorCode":null,"errorMessage":"Unable to get database path for this platform. Make sure the native module is properly loaded.","messagePattern":"Unable to get database path for this platform\\. Make sure the native module is properly loaded\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"bindings/react-native/src/index.ts","lineNumber":96,"sourceCode":"\n/**\n * Helper function to construct a database path in a writable directory.\n *\n * @param filename - Database filename (e.g., 'mydb.db')\n * @returns Absolute path to the database file\n *\n * @example\n * ```ts\n * import { getDbPath, connect } from '@tursodatabase/sync-react-native';\n *\n * const dbPath = getDbPath('mydb.db');\n * const db = await connect({ path: dbPath });\n * ```\n */\nexport function getDbPath(filename: string): string {\n  const basePath = paths.database;\n  if (!basePath || basePath === '.') {\n    throw new Error(\n      'Unable to get database path for this platform. ' +\n      'Make sure the native module is properly loaded.'\n    );\n  }\n  return `${basePath}/${filename}`;\n}\n\n/**\n * Connect to a database asynchronously (matches JavaScript bindings API)\n *\n * This is the main entry point for the SDK, matching the API from\n * @tursodatabase/sync-native and @tursodatabase/database-native.\n *\n * **Path handling**: Relative paths are automatically placed in writable directories:\n * - Android: app's database directory (`/data/data/com.app/databases/`)\n * - iOS: app's documents directory\n *\n * Absolute paths and `:memory:` are used as-is.","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/tursodatabase/turso/blob/bad083fafbefdeae9a42ec19bdaaad8918dcf411/bindings/react-native/src/index.ts#L78-L114","documentation":"getDbPath(filename) joins a native-provided base directory (paths.database, exposed by the native module) with the filename. If that base is falsy or the literal '.', path resolution produced nothing usable and the helper refuses to hand back a bogus path. It indicates the native side did not populate platform paths for the current environment.","triggerScenarios":"Calling getDbPath on a platform or build where the native module exists but its paths.database is empty/'.'; invoking it before native initialization populated the paths object; a custom/new platform target that never implemented the paths API.","commonSituations":"Porting the app to a new platform or unusual build flavor; exotic test harnesses that load the module without full native startup; upgrading native revisions where the paths accessor changed.","solutions":["Build the path yourself with a filesystem library: react-native-fs RNFS.DocumentDirectoryPath or expo-file-system documentDirectory","Verify the native module revision matches the JS package (pod install / clean gradle build)","Log the native paths object to confirm which fields are populated on the target platform","If the platform should be supported, report it with the native module version"],"exampleFix":"// before\nimport { getDbPath } from '@tursodatabase/sync-react-native';\nconst p = getDbPath('mydb.db'); // throws: Unable to get database path for this platform\n\n// after\nimport RNFS from 'react-native-fs';\nconst p = `${RNFS.DocumentDirectoryPath}/mydb.db`;","handlingStrategy":"validation","validationCode":"import RNFS from 'react-native-fs';\nimport { getDbPath } from '@tursodatabase/sync-react-native';\n\nfunction safeDbPath(filename: string): string {\n  try {\n    return getDbPath(filename);\n  } catch {\n    const base = RNFS.DocumentDirectoryPath;\n    if (!base) throw new Error('No writable directory available on this platform');\n    return `${base}/${filename}`;\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  path = getDbPath('mydb.db');\n} catch (e) {\n  if (String((e as Error).message).includes('Unable to get database path')) {\n    path = `${RNFS.DocumentDirectoryPath}/mydb.db`; // platform FS fallback\n  } else throw e;\n}","preventionTips":["Keep react-native-fs or expo-file-system available as a path source you control","Smoke-test getDbPath() on every platform flavor you ship","Align native module and JS package versions so paths.database stays populated"],"tags":["path-resolution","platform","native-module","react-native"],"backgroundTag":"path-resolution-failed","analyzedSha":"bad083fafbefdeae9a42ec19bdaaad8918dcf411","analyzedAt":"2026-08-16T23:12:11.798Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}