tursodatabase/turso · error · Error
Unable to get database path for this platform. Make sure the
Error message
Unable to get database path for this platform. Make sure the native module is properly loaded.
What it means
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.
Source
Thrown at bindings/react-native/src/index.ts:96
/**
* Helper function to construct a database path in a writable directory.
*
* @param filename - Database filename (e.g., 'mydb.db')
* @returns Absolute path to the database file
*
* @example
* ```ts
* import { getDbPath, connect } from '@tursodatabase/sync-react-native';
*
* const dbPath = getDbPath('mydb.db');
* const db = await connect({ path: dbPath });
* ```
*/
export function getDbPath(filename: string): string {
const basePath = paths.database;
if (!basePath || basePath === '.') {
throw new Error(
'Unable to get database path for this platform. ' +
'Make sure the native module is properly loaded.'
);
}
return `${basePath}/${filename}`;
}
/**
* Connect to a database asynchronously (matches JavaScript bindings API)
*
* This is the main entry point for the SDK, matching the API from
* @tursodatabase/sync-native and @tursodatabase/database-native.
*
* **Path handling**: Relative paths are automatically placed in writable directories:
* - Android: app's database directory (`/data/data/com.app/databases/`)
* - iOS: app's documents directory
*
* Absolute paths and `:memory:` are used as-is.View on GitHub (pinned to bad083fafb)
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
Example fix
// before
import { getDbPath } from '@tursodatabase/sync-react-native';
const p = getDbPath('mydb.db'); // throws: Unable to get database path for this platform
// after
import RNFS from 'react-native-fs';
const p = `${RNFS.DocumentDirectoryPath}/mydb.db`; Defensive patterns
Strategy: validation
Validate before calling
import RNFS from 'react-native-fs';
import { getDbPath } from '@tursodatabase/sync-react-native';
function safeDbPath(filename: string): string {
try {
return getDbPath(filename);
} catch {
const base = RNFS.DocumentDirectoryPath;
if (!base) throw new Error('No writable directory available on this platform');
return `${base}/${filename}`;
}
} Try / catch
try {
path = getDbPath('mydb.db');
} catch (e) {
if (String((e as Error).message).includes('Unable to get database path')) {
path = `${RNFS.DocumentDirectoryPath}/mydb.db`; // platform FS fallback
} else throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Turso native module not loaded
- @tursodatabase/sync-react-native: Native module not found. M
- Encryption is not supported in this build
- Encryption is not supported in this build
- push() is only available for sync databases
AI-assisted analysis of tursodatabase/turso@bad083fafb (2026-08-16).
Data as JSON: /api/errors/3146c7cfaa98c619.
Report an issue: GitHub.