Amplify datastore is not using sqlite
Before opening, please confirm:
- [x] I have searched for duplicate or closed issues and discussions.
- [x] I have read the guide for submitting bug reports.
- [x] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
JavaScript Framework
React Native
Amplify APIs
DataStore
Amplify Version
v6
Amplify Categories
storage
Backend
Amplify CLI
Environment information
# Put output below this line
% npx envinfo --system --binaries --browsers --npmPackages --duplicates --npmGlobalPackages
System:
OS: macOS 15.5
CPU: (14) arm64 Apple M4 Pro
Memory: 288.52 MB / 24.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.12.0 - /usr/local/bin/node
npm: 10.5.0 - /usr/local/bin/npm
Watchman: 2025.05.19.00 - /opt/homebrew/bin/watchman
Browsers:
Chrome: 137.0.7151.120
Safari: 18.5
npmPackages:
@aws-amplify/datastore-storage-adapter: ^2.0.30 => 2.1.84
@aws-amplify/react-native: ^1.1.10 => 1.1.10
@aws-amplify/ui-react-native: ^2.2.13 => 2.5.1
@aws-sdk/client-cognito-identity-provider: ^3.677.0 => 3.787.0
@aws-sdk/client-eventbridge: ^3.749.0 => 3.787.0
@aws-sdk/client-lambda: ^3.734.0 => 3.787.0
@aws-sdk/client-location: ^3.665.0 => 3.787.0
@aws-sdk/client-scheduler: ^3.750.0 => 3.787.0
@aws-sdk/client-ses: ^3.758.0 => 3.787.0
@aws-sdk/client-sns: ^3.696.0 => 3.787.0
@aws-sdk/credential-providers: ^3.678.0 => 3.787.0
@azure/core-asynciterator-polyfill: ^1.0.2 => 1.0.2
@babel/core: ^7.20.0 => 7.26.10
@babel/plugin-transform-class-static-block: ^7.26.0 => 7.26.0
@expo/vector-icons: ^14.0.2 => 14.1.0
@react-native-async-storage/async-storage: 1.23.1 => 1.23.1
@react-native-clipboard/clipboard: ^1.16.1 => 1.16.2
@react-native-community/netinfo: 11.3.1 => 11.3.1
@react-native-picker/picker: 2.7.5 => 2.7.5
@react-navigation/native: ^6.0.2 => 6.1.18
@types/jest: ^29.5.12 => 29.5.14
@types/react: ~18.2.45 => 18.2.79
@types/react-native-vector-icons: ^6.4.18 => 6.4.18
@types/react-test-renderer: ^18.0.7 => 18.3.1
@types/xml2js: ^0.4.14 => 0.4.14
HelloWorld: 0.0.1
aws-amplify: ^6.15.1 => 6.15.1
aws-amplify/adapter-core: undefined ()
aws-amplify/adapter-core/internals: undefined ()
aws-amplify/analytics: undefined ()
aws-amplify/analytics/kinesis: undefined ()
aws-amplify/analytics/kinesis-firehose: undefined ()
aws-amplify/analytics/personalize: undefined ()
aws-amplify/analytics/pinpoint: undefined ()
aws-amplify/api: undefined ()
aws-amplify/api/internals: undefined ()
aws-amplify/api/server: undefined ()
aws-amplify/auth: undefined ()
aws-amplify/auth/cognito: undefined ()
aws-amplify/auth/cognito/server: undefined ()
aws-amplify/auth/enable-oauth-listener: undefined ()
aws-amplify/auth/server: undefined ()
aws-amplify/data: undefined ()
aws-amplify/data/server: undefined ()
aws-amplify/datastore: undefined ()
aws-amplify/in-app-messaging: undefined ()
aws-amplify/in-app-messaging/pinpoint: undefined ()
aws-amplify/push-notifications: undefined ()
aws-amplify/push-notifications/pinpoint: undefined ()
aws-amplify/storage: undefined ()
aws-amplify/storage/s3: undefined ()
aws-amplify/storage/s3/server: undefined ()
aws-amplify/storage/server: undefined ()
aws-amplify/utils: undefined ()
babel-preset-expo: ~11.0.0 => 11.0.15
blob-polyfill: ^9.0.20240710 => 9.0.20240710
expo: ~51.0.28 => 51.0.39
expo-asset: ~10.0.10 => 10.0.10
expo-build-properties: ~0.12.5 => 0.12.5
expo-constants: ~16.0.2 => 16.0.2
expo-dev-client: ~4.0.27 => 4.0.29
expo-file-system: ~17.0.1 => 17.0.1
expo-font: ~12.0.9 => 12.0.10
expo-linking: ~6.3.1 => 6.3.1
expo-location: ~17.0.1 => 17.0.1
expo-router: ~3.5.23 => 3.5.24
expo-splash-screen: ~0.27.7 => 0.27.7
expo-sqlite: ~14.0.6 => 14.0.6
expo-status-bar: ~1.12.1 => 1.12.1
expo-system-ui: ~3.0.7 => 3.0.7
expo-task-manager: ~11.8.2 => 11.8.2
expo-web-browser: ~13.0.3 => 13.0.3
fast-xml-parser: ^5.2.1 => 5.2.1 (4.5.3, 4.4.1)
firebase: ^11.9.1 => 11.9.1
firebase/ai: undefined ()
firebase/analytics: undefined ()
firebase/app: undefined ()
firebase/app-check: undefined ()
firebase/auth: undefined ()
firebase/auth/cordova: undefined ()
firebase/auth/web-extension: undefined ()
firebase/compat: undefined ()
firebase/compat/analytics: undefined ()
firebase/compat/app: undefined ()
firebase/compat/app-check: undefined ()
firebase/compat/auth: undefined ()
firebase/compat/database: undefined ()
firebase/compat/firestore: undefined ()
firebase/compat/functions: undefined ()
firebase/compat/installations: undefined ()
firebase/compat/messaging: undefined ()
firebase/compat/performance: undefined ()
firebase/compat/remote-config: undefined ()
firebase/compat/storage: undefined ()
firebase/data-connect: undefined ()
firebase/database: undefined ()
firebase/firestore: undefined ()
firebase/firestore/lite: undefined ()
firebase/functions: undefined ()
firebase/installations: undefined ()
firebase/messaging: undefined ()
firebase/messaging/sw: undefined ()
firebase/performance: undefined ()
firebase/remote-config: undefined ()
firebase/storage: undefined ()
firebase/vertexai: undefined ()
gpxparser: ^3.0.8 => 3.0.8
jest: ^29.2.1 => 29.7.0
jest-expo: ~51.0.3 => 51.0.4
react: 18.2.0 => 18.2.0
react-dom: 18.2.0 => 18.2.0
react-native: 0.74.5 => 0.74.5
react-native-exit-app: ^2.0.0 => 2.0.0
react-native-gesture-handler: ~2.16.1 => 2.16.2
react-native-get-random-values: ~1.11.0 => 1.11.0
react-native-keyboard-aware-scroll-view: ^0.9.5 => 0.9.5
react-native-maps: ~1.18.0 => 1.18.0
react-native-paper: ^5.12.5 => 5.13.1
react-native-picker-select: ^9.3.1 => 9.3.1
react-native-reanimated: ~3.10.1 => 3.10.1
react-native-safe-area-context: 4.10.5 => 4.10.5
react-native-screens: 3.31.1 => 3.31.1
react-native-sqlite-storage: ^6.0.1 => 6.0.1
react-native-svg: 15.2.0 => 15.2.0
react-native-vector-icons: ^10.2.0 => 10.2.0
react-native-web: ~0.19.10 => 0.19.13
react-test-renderer: 18.2.0 => 18.2.0
typescript: ~5.3.3 => 5.3.3
xml2js: ^0.6.2 => 0.6.2 (0.6.0)
npmGlobalPackages:
@aws-amplify/cli: 12.13.1
corepack: 0.25.2
eas-cli: 16.6.2
expo-cli: 6.3.10
firebase-tools: 14.7.0
npm-check-updates: 17.1.13
npm: 10.5.0
react-devtools: 6.1.1
Describe the bug
Using a clean install of the example project here:
https://docs.amplify.aws/gen1/react-native/build-a-backend/more-features/datastore/set-up-datastore/#setup-local-development-environment
Amplify DataStore stores the database in Async Storage rather than Sqlite on the Android mobile phone.
Expected behavior
I want the database to be stored in sqlite. In my real app, I have many thousands of records which won't work well with Async storage.
Reproduction steps
Ref: https://docs.amplify.aws/gen1/react-native/build-a-backend/more-features/datastore/set-up-datastore/
% npx create-expo-app AmplifyDataStoreExpo % cd AmplifyDataStoreExpo % npx expo install aws-amplify @aws-amplify/react-native @react-native-community/netinfo @aws-amplify/datastore-storage-adapter react-% % native-sqlite-storage @react-native-async-storage/async-storage react-native-get-random-values @azure/core-asynciterator-polyfill
% npm install
% npx expo start --dev-client
% npx expo install expo-linking
% npm run reset-project
% npx expo run:android
% amplify init // Gen 1
% amplify add api
% npm install aws-amplify
Add to schema.graphql:
type Post @model {
id: ID!
title: String!
status: PostStatus!
rating: Int
content: String
}
enum PostStatus {
ACTIVE
INACTIVE
}
% npx amplify-app
% amplify codegen models
Updated app/index.tsx - see 'Code snippet' section of this issue.
Error:
Android Bundling failed 1896ms node_modules/expo-router/entry.js (2026 modules) Unable to resolve "../dist/aws-amplify-datastore-sqlite-adapter-expo.min.js" from "node_modules/@aws-amplify/datastore-storage-adapter/ExpoSQLiteAdapter/index.js"
package.json:
Tried default/latest: "@aws-amplify/datastore-storage-adapter": "^2.1.84", Also reverted to this version as per https://github.com/aws-amplify/amplify-js/issues/12801 "@aws-amplify/datastore-storage-adapter": "^2.0.30",
Fixed various build errors with:
% rm -rf node_modules % npm install
% cp node_modules/@aws-amplify/datastore-storage-adapter/dist/umd/* node_modules/@aws-amplify/datastore-storage-adapter/dist % npx expo install expo-sqlite % npx expo install @aws-amplify/core
% npx expo prebuild % npx expo start -c % npx expo run:android % rm -rf node_modules package-lock.json yarn.lock
Code Snippet
// Put your code below this line.
// index.tsx // Configures Amplify DataStore to use SQLITE adapter // Saves and queries an entry // Logs both document director (which should store SQL .db files and Async storage
import { ExpoSQLiteAdapter } from "@aws-amplify/datastore-storage-adapter/ExpoSQLiteAdapter"; import "@azure/core-asynciterator-polyfill"; import AsyncStorage from "@react-native-async-storage/async-storage"; import { DataStore } from "aws-amplify/datastore"; import * as FileSystem from "expo-file-system"; import React, { useEffect, useState } from "react"; import { Button, Platform, Text, View } from "react-native"; import { Post } from "../src/models"; // Adjust path if needed
// Configure DataStore before rendering the app DataStore.configure({ storageAdapter: ExpoSQLiteAdapter, });
async function logDataStoreDbSize() {
if (Platform.OS === "android") {
const dbPath = ${FileSystem.documentDirectory}datastore/AmplifyDatastore.db;
const info = await FileSystem.getInfoAsync(dbPath);
if (info.exists) {
console.log(DataStore DB size: ${info.size} bytes);
} else {
console.log("DataStore DB file does not exist at:", dbPath);
}
}
}
async function logAllFilesRecursively(
dir: string = FileSystem.documentDirectory ?? "",
prefix = ""
) {
try {
const safeDir = dir ?? "";
const items = await FileSystem.readDirectoryAsync(safeDir);
for (const item of items) {
const path = safeDir + item;
const info = await FileSystem.getInfoAsync(path);
if (info.isDirectory) {
await logAllFilesRecursively(path + "/", prefix + item + "/");
} else {
if (info.exists) {
console.log(File: ${prefix}${item}, size: ${info.size} bytes);
} else {
console.log(File: ${prefix}${item} does not exist);
}
}
}
} catch (e) {
console.log(Error reading directory ${dir}:, e);
}
}
async function logAllAsyncStorageKeysAndValues() {
try {
const keys = await AsyncStorage.getAllKeys();
console.log("All AsyncStorage keys:", keys);
for (const key of keys) {
const value = await AsyncStorage.getItem(key);
console.log(Key: ${key}\nValue: ${value}\n);
}
} catch (e) {
console.error("Error reading AsyncStorage:", e);
}
}
const onPressFabUserOne = async () => { console.log("onPressFabUserOne()"); console.log( "DBG: DOCUMENT DIR (INC SQLITE) ------------------------------------" ); await logAllFilesRecursively(); await logDataStoreDbSize(); console.log("DBG: ASYNC STORAGE ------------------------------------"); await logAllAsyncStorageKeysAndValues(); };
export default function Index() { const [message, setMessage] = useState("Loading...");
useEffect(() => { async function saveAndQueryPosts() { try { // Save a new post const post = await DataStore.save( new Post({ title: "My First Post", status: "ACTIVE", // or use a valid PostStatus value }) ); console.log("Post saved successfully!", post);
// Query all posts
const posts = await DataStore.query(Post);
console.log(
"Posts retrieved successfully!",
JSON.stringify(posts, null, 2)
);
setMessage(`Saved and retrieved ${posts.length} post(s)!`);
} catch (error) {
setMessage("Error saving or retrieving posts");
console.log("Error saving or retrieving posts", error);
}
}
saveAndQueryPosts();
}, []);
return ( <View> <Text>{message}</Text> <Button title="Check DataStore Storage" onPress={onPressFabUserOne} /> </View> ); }
Log output
// Put your logs below this line
DBG: DOCUMENT DIR (INC SQLITE) ------------------------------------
index.tsx:45 File: rList, size: 84 bytes
index.tsx:45 File: profileInstalled, size: 24 bytes
index.tsx:45 File: DevLauncherApp-BridgelessReactNativeDevBundle.js, size: 9611836 bytes
index.tsx:26 DataStore DB file does not exist at: file:///data/user/0/com.richstimson.AmplifyDataStoreExpo/files/datastore/AmplifyDatastore.db
index.tsx:76 DBG: ASYNC STORAGE ------------------------------------
index.tsx:59 All AsyncStorage keys: Array(10)
index.tsx:62 Key: @AmplifyDatastore::datastore_Setting::Data::01JY99EP9B15Z4J526J50ANET6::01JY99ED0ZSTATD7YHCA2BXTZS
Value: {"key":"schemaVersion","value":"\"066d19b25220b01d17dc20ce323843c6\"","id":"01JY99ED0ZSTATD7YHCA2BXTZS"}
index.tsx:62 Key: @AmplifyDatastore::sync_ModelMetadata::Data::01JY9AGWHQQ2AX9C67JAYFHCRF::01JY9AGCBEWNG1N3M97J18MEMV
Value: {"model":"Todo","namespace":"user","lastSync":null,"fullSyncInterval":86400000,"lastFullSync":null,"lastSyncPredicate":null,"id":"01JY9AGCBEWNG1N3M97J18MEMV"}
index.tsx:62 Key: @AmplifyDatastore::sync_ModelMetadata::Data::01JY9AGWJDGQCYMEKKATFRF9SA::01JY9AGCBEWNG1N3M97J18MEMW
Value: {"model":"Post","namespace":"user","lastSync":null,"fullSyncInterval":86400000,"lastFullSync":null,"lastSyncPredicate":null,"id":"01JY9AGCBEWNG1N3M97J18MEMW"}
index.tsx:62 Key: @AmplifyDatastore::sync_ModelMetadata::Data::01JY9AGXK5MCNZNP8MD3VN1HS0::01JY9AGCBEWNG1N3M97J18MEMW
Value: {"model":"Post","namespace":"user","lastSync":1750512203173,"fullSyncInterval":86400000,"lastFullSync":1750512203173,"lastSyncPredicate":null,"id":"01JY9AGCBEWNG1N3M97J18MEMW"}
index.tsx:62 Key: @AmplifyDatastore::sync_ModelMetadata::Data::01JY9AGXM25R181YZPBJ2QK9JY::01JY9AGCBEWNG1N3M97J18MEMV
Value: {"model":"Todo","namespace":"user","lastSync":1750512203173,"fullSyncInterval":86400000,"lastFullSync":1750512203173,"lastSyncPredicate":null,"id":"01JY9AGCBEWNG1N3M97J18MEMV"}
index.tsx:62 Key: @AmplifyDatastore::user_Post::Data::01JY99EPAQ9Q982KQ4YMVSE3C2::bb34139d-6cd6-405e-9555-a1b719c8a61f
Value: {"title":"My First Post","status":"ACTIVE","id":"bb34139d-6cd6-405e-9555-a1b719c8a61f","rating":null,"content":null,"createdAt":null,"updatedAt":null}
index.tsx:62 Key: @AmplifyDatastore::user_Post::Data::01JY9AAV3HKF855D2E6NZPKNVM::aed21185-37ac-4018-8e83-1bd756ab582d
Value: {"title":"My First Post","status":"ACTIVE","id":"aed21185-37ac-4018-8e83-1bd756ab582d","rating":null,"content":null,"createdAt":null,"updatedAt":null}
aws-exports.js
const awsmobile = {
"aws_project_region": "us-east-1",
"aws_appsync_graphqlEndpoint": "https://dpgggcvmczgsvjo4prd6xrv6ei.appsync-api.us-east-1.amazonaws.com/graphql",
"aws_appsync_region": "us-east-1",
"aws_appsync_authenticationType": "API_KEY",
"aws_appsync_apiKey": "da2-rhoriwaiwnfrxjazzeavlqo3yy"
};
Manual configuration
No response
Additional configuration
No response
Mobile Device
Samsung Galaxy A05
Mobile Operating System
Android 14
Mobile Browser
N/A
Mobile Browser Version
N/A
Additional information and screenshots
package.json:
{ "name": "amplifydatastoreexpo", "main": "expo-router/entry", "version": "1.0.0", "scripts": { "start": "expo start", "reset-project": "node ./scripts/reset-project.js", "android": "expo run:android", "ios": "expo run:ios", "web": "expo start --web", "lint": "expo lint", "amplify-modelgen": "node amplify/scripts/amplify-modelgen.js", "amplify-push": "node amplify/scripts/amplify-push.js" }, "dependencies": { "@aws-amplify/datastore-storage-adapter": "2.0.30", "@aws-amplify/react-native": "^1.1.10", "@azure/core-asynciterator-polyfill": "^1.0.2", "@expo/vector-icons": "^14.1.0", "@react-native-async-storage/async-storage": "2.1.2", "@react-native-community/netinfo": "11.4.1", "@react-navigation/bottom-tabs": "^7.3.10", "@react-navigation/elements": "^2.3.8", "@react-navigation/native": "^7.1.6", "aws-amplify": "^6.15.1", "expo": "~53.0.12", "expo-blur": "~14.1.5", "expo-constants": "~17.1.6", "expo-dev-client": "~5.2.1", "expo-font": "~13.3.1", "expo-haptics": "~14.1.4", "expo-image": "~2.3.0", "expo-linking": "~7.1.5", "expo-router": "~5.1.0", "expo-splash-screen": "~0.30.9", "expo-status-bar": "~2.2.3", "expo-symbols": "~0.4.5", "expo-system-ui": "~5.0.9", "expo-web-browser": "~14.2.0", "react": "19.0.0", "react-dom": "19.0.0", "react-native": "0.79.4", "react-native-gesture-handler": "~2.24.0", "react-native-get-random-values": "~1.11.0", "react-native-reanimated": "~3.17.4", "react-native-safe-area-context": "5.4.0", "react-native-screens": "~4.11.1", "react-native-sqlite-storage": "^6.0.1", "react-native-web": "~0.20.0", "react-native-webview": "13.13.5", "expo-sqlite": "~15.2.12", "@expo/metro-runtime": "~5.0.4" }, "devDependencies": { "@babel/core": "^7.25.2", "@types/react": "~19.0.10", "eslint": "^9.25.0", "eslint-config-expo": "~9.2.0", "typescript": "~5.8.3", "ini": "^1.3.5", "inquirer": "^6.5.1" }, "private": true }
Hi, thanks for reporting. We will investigate and get back to you once we have more information.
Thanks!
This issue appears to be a duplicate of #14514 - both are experiencing the same problem where ExpoSQLiteAdapter is not properly exported and falls back to AsyncStorage instead of SQLite.
The root cause is:
- ExpoSQLiteAdapter not being exported from the package
- Using deprecated
openDatabaseAPI that doesn't exist in modern expo-sqlite versions
This should be resolved by PR #14565 which:
- Exports ExpoSQLiteAdapter properly
- Modernizes the implementation to use expo-sqlite 13.0+ async APIs
- Fixes the silent fallback to AsyncStorage
@richstimson Once PR #14565 is merged, you should be able to use ExpoSQLiteAdapter correctly with modern Expo SDK versions.