# react-native-async-storage/async-storage architecture

> Architecture diagram of the GitHub repository react-native-async-storage/async-storage, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/react-native-async-storage/async-storage
- Repository: https://github.com/react-native-async-storage/async-storage

## Overview

React Native Async Storage exposes asynchronous key-value operations, including batch access and named databases, over platform-specific persistent backends. A client uses the JavaScript API, which dispatches to native storage or the web implementation; native calls reach platform adapters and, on Android and Apple platforms, shared SQLite storage. Windows uses a legacy fallback, while the README documents IndexedDB for web and legacy fallbacks for visionOS and Windows. The graph preserves documented platform capabilities, but some links to unsampled web and legacy implementations are necessarily unverified.

Main entry points: [`shared-storage/src/commonMain/kotlin/org/asyncstorage/shared_storage/SharedStorageImpl.kt`](https://github.com/react-native-async-storage/async-storage/blob/main/shared-storage/src/commonMain/kotlin/org/asyncstorage/shared_storage/SharedStorageImpl.kt) (Storage implementation), [`packages/async-storage/src/native-module/NativeAsyncStorage.ts`](https://github.com/react-native-async-storage/async-storage/blob/main/packages/async-storage/src/native-module/NativeAsyncStorage.ts) (Native bridge), [`packages/async-storage/apple/storage/RNStorage.swift`](https://github.com/react-native-async-storage/async-storage/blob/main/packages/async-storage/apple/storage/RNStorage.swift) (Apple adapter), [`shared-storage/src/commonMain/kotlin/org/asyncstorage/shared_storage/SharedStorage.kt`](https://github.com/react-native-async-storage/async-storage/blob/main/shared-storage/src/commonMain/kotlin/org/asyncstorage/shared_storage/SharedStorage.kt) (Shared storage API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_js["JavaScript API"]
  node_api["Storage API<br/>[AsyncStorage.ts]"]
  node_factory["Native factory"]
  node_nativejs["Native bridge"]
  node_webfactory["Web factory"]
end

subgraph group_platform["Platform Adapters"]
  node_webstorage["IndexedDB storage"]
  node_webregistry["Connection registry"]
  node_androidmodule["Android module"]
  node_androidregistry["Android registry<br/>[StorageRegistry.kt]"]
  node_androidstorage["Android adapter<br/>[RNStorage.kt]"]
  node_applemodule["Apple adapter<br/>[RNStorage.swift]"]
  node_appleregistry["Apple registry"]
end

subgraph group_shared["Shared SQLite"]
  node_sharedapi["Shared storage API<br/>[SharedStorage.kt]"]
  node_sharedimpl["Storage implementation"]
  node_roomdb[("Room database<br/>[StorageDatabase.kt]")]
  node_androidplatform["Android database setup"]
  node_appleplatform["Apple database setup"]
end

subgraph group_legacy["Legacy Backends"]
  node_windowsfactory["Windows fallback"]
  node_windowsdb[("Windows SQLite<br/>[DBStorage.cpp]")]
end

node_app(("React Native app"))

node_app -->|"uses"| node_api
node_api -.->|"creates"| node_factory
node_factory -->|"dispatches"| node_nativejs
node_app -.->|"uses on web"| node_webfactory
node_webfactory -.->|"selects"| node_webstorage
node_webstorage -->|"uses connections"| node_webregistry
node_nativejs -.->|"calls"| node_androidmodule
node_androidmodule -->|"dispatches"| node_androidregistry
node_androidregistry -->|"selects"| node_androidstorage
node_androidstorage -->|"calls"| node_sharedapi
node_nativejs -.->|"calls"| node_applemodule
node_applemodule -->|"calls"| node_sharedapi
node_appleregistry -->|"registers"| node_applemodule
node_sharedapi -->|"implemented by"| node_sharedimpl
node_sharedimpl -->|"queries"| node_roomdb
node_androidplatform -->|"constructs"| node_sharedimpl
node_androidplatform -->|"opens"| node_roomdb
node_appleplatform -->|"constructs"| node_sharedimpl
node_appleplatform -->|"opens"| node_roomdb
node_app -.->|"uses on Windows"| node_windowsfactory
node_windowsfactory -.->|"calls legacy module"| node_windowsdb

click node_api "https://github.com/react-native-async-storage/async-storage/blob/main/packages/async-storage/src/AsyncStorage.ts"
click node_factory "https://github.com/react-native-async-storage/async-storage/blob/main/packages/async-storage/src/createAsyncStorage.native.ts"
click node_nativejs "https://github.com/react-native-async-storage/async-storage/blob/main/packages/async-storage/src/native-module/NativeAsyncStorage.ts"
click node_webfactory "https://github.com/react-native-async-storage/async-storage/blob/main/packages/async-storage/src/createAsyncStorage.ts"
click node_webstorage "https://github.com/react-native-async-storage/async-storage/blob/main/packages/async-storage/src/web-module/IndexedDBStorage.ts"
click node_webregistry "https://github.com/react-native-async-storage/async-storage/blob/main/packages/async-storage/src/web-module/IndexedDBConnectionRegistry.ts"
click node_androidmodule "https://github.com/react-native-async-storage/async-storage/blob/main/packages/async-storage/android/src/main/kotlin/org/asyncstorage/legacy_storage/LegacyStorageModule.kt"
click node_androidregistry "https://github.com/react-native-async-storage/async-storage/blob/main/packages/async-storage/android/src/main/kotlin/org/asyncstorage/storage/StorageRegistry.kt"
click node_androidstorage "https://github.com/react-native-async-storage/async-storage/blob/main/packages/async-storage/android/src/main/kotlin/org/asyncstorage/storage/RNStorage.kt"
click node_applemodule "https://github.com/react-native-async-storage/async-storage/blob/main/packages/async-storage/apple/storage/RNStorage.swift"
click node_appleregistry "https://github.com/react-native-async-storage/async-storage/blob/main/packages/async-storage/apple/storage/StorageRegistry.swift"
click node_windowsfactory "https://github.com/react-native-async-storage/async-storage/blob/main/packages/async-storage/src/createAsyncStorage.windows.ts"
click node_windowsdb "https://github.com/react-native-async-storage/async-storage/blob/main/packages/async-storage/windows/code/DBStorage.cpp"
click node_sharedapi "https://github.com/react-native-async-storage/async-storage/blob/main/shared-storage/src/commonMain/kotlin/org/asyncstorage/shared_storage/SharedStorage.kt"
click node_sharedimpl "https://github.com/react-native-async-storage/async-storage/blob/main/shared-storage/src/commonMain/kotlin/org/asyncstorage/shared_storage/SharedStorageImpl.kt"
click node_roomdb "https://github.com/react-native-async-storage/async-storage/blob/main/shared-storage/src/commonMain/kotlin/org/asyncstorage/shared_storage/database/StorageDatabase.kt"
click node_androidplatform "https://github.com/react-native-async-storage/async-storage/blob/main/shared-storage/src/androidMain/kotlin/org/asyncstorage/shared_storage/SharedStorage.android.kt"
click node_appleplatform "https://github.com/react-native-async-storage/async-storage/blob/main/shared-storage/src/appleMain/kotlin/org/asyncstorage/shared_storage/SharedStorage.apple.kt"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_api,node_factory,node_nativejs,node_webfactory toneBlue
class node_webstorage,node_webregistry,node_androidmodule,node_androidregistry,node_androidstorage,node_applemodule,node_appleregistry toneAmber
class node_sharedapi,node_sharedimpl,node_roomdb,node_androidplatform,node_appleplatform toneMint
class node_windowsfactory,node_windowsdb toneRose
class node_app toneIndigo
```

## Components

### JavaScript API

- [Storage API](https://github.com/react-native-async-storage/async-storage/blob/main/packages/async-storage/src/AsyncStorage.ts): `packages/async-storage/src/AsyncStorage.ts`
- [Native factory](https://github.com/react-native-async-storage/async-storage/blob/main/packages/async-storage/src/createAsyncStorage.native.ts): `packages/async-storage/src/createAsyncStorage.native.ts`
- [Native bridge](https://github.com/react-native-async-storage/async-storage/blob/main/packages/async-storage/src/native-module/NativeAsyncStorage.ts): `packages/async-storage/src/native-module/NativeAsyncStorage.ts`
- [Web factory](https://github.com/react-native-async-storage/async-storage/blob/main/packages/async-storage/src/createAsyncStorage.ts): `packages/async-storage/src/createAsyncStorage.ts`

### Platform Adapters

- [IndexedDB storage](https://github.com/react-native-async-storage/async-storage/blob/main/packages/async-storage/src/web-module/IndexedDBStorage.ts): `packages/async-storage/src/web-module/IndexedDBStorage.ts`
- [Connection registry](https://github.com/react-native-async-storage/async-storage/blob/main/packages/async-storage/src/web-module/IndexedDBConnectionRegistry.ts): `packages/async-storage/src/web-module/IndexedDBConnectionRegistry.ts`
- [Android module](https://github.com/react-native-async-storage/async-storage/blob/main/packages/async-storage/android/src/main/kotlin/org/asyncstorage/legacy_storage/LegacyStorageModule.kt): `packages/async-storage/android/src/main/kotlin/org/asyncstorage/legacy_storage/LegacyStorageModule.kt`
- [Android registry](https://github.com/react-native-async-storage/async-storage/blob/main/packages/async-storage/android/src/main/kotlin/org/asyncstorage/storage/StorageRegistry.kt): `packages/async-storage/android/src/main/kotlin/org/asyncstorage/storage/StorageRegistry.kt`
- [Android adapter](https://github.com/react-native-async-storage/async-storage/blob/main/packages/async-storage/android/src/main/kotlin/org/asyncstorage/storage/RNStorage.kt): `packages/async-storage/android/src/main/kotlin/org/asyncstorage/storage/RNStorage.kt`
- [Apple adapter](https://github.com/react-native-async-storage/async-storage/blob/main/packages/async-storage/apple/storage/RNStorage.swift): `packages/async-storage/apple/storage/RNStorage.swift`
- [Apple registry](https://github.com/react-native-async-storage/async-storage/blob/main/packages/async-storage/apple/storage/StorageRegistry.swift): `packages/async-storage/apple/storage/StorageRegistry.swift`

### Shared SQLite

- [Shared storage API](https://github.com/react-native-async-storage/async-storage/blob/main/shared-storage/src/commonMain/kotlin/org/asyncstorage/shared_storage/SharedStorage.kt): `shared-storage/src/commonMain/kotlin/org/asyncstorage/shared_storage/SharedStorage.kt`
- [Storage implementation](https://github.com/react-native-async-storage/async-storage/blob/main/shared-storage/src/commonMain/kotlin/org/asyncstorage/shared_storage/SharedStorageImpl.kt): `shared-storage/src/commonMain/kotlin/org/asyncstorage/shared_storage/SharedStorageImpl.kt`
- [Room database](https://github.com/react-native-async-storage/async-storage/blob/main/shared-storage/src/commonMain/kotlin/org/asyncstorage/shared_storage/database/StorageDatabase.kt): `shared-storage/src/commonMain/kotlin/org/asyncstorage/shared_storage/database/StorageDatabase.kt`
- [Android database setup](https://github.com/react-native-async-storage/async-storage/blob/main/shared-storage/src/androidMain/kotlin/org/asyncstorage/shared_storage/SharedStorage.android.kt): `shared-storage/src/androidMain/kotlin/org/asyncstorage/shared_storage/SharedStorage.android.kt`
- [Apple database setup](https://github.com/react-native-async-storage/async-storage/blob/main/shared-storage/src/appleMain/kotlin/org/asyncstorage/shared_storage/SharedStorage.apple.kt): `shared-storage/src/appleMain/kotlin/org/asyncstorage/shared_storage/SharedStorage.apple.kt`

### Legacy Backends

- [Windows fallback](https://github.com/react-native-async-storage/async-storage/blob/main/packages/async-storage/src/createAsyncStorage.windows.ts): `packages/async-storage/src/createAsyncStorage.windows.ts`
- [Windows SQLite](https://github.com/react-native-async-storage/async-storage/blob/main/packages/async-storage/windows/code/DBStorage.cpp): `packages/async-storage/windows/code/DBStorage.cpp`

### Other components

- **React Native app**

## Connections

- React Native app → Storage API: uses (evidence: `README.md`)
- Storage API → Native factory: creates (evidence: `packages/async-storage/src/createAsyncStorage.native.ts`)
- Native factory → Native bridge: dispatches (evidence: `packages/async-storage/src/createAsyncStorage.native.ts`)
- React Native app → Web factory: uses on web (evidence: `README.md`)
- Web factory → IndexedDB storage: selects
- IndexedDB storage → Connection registry: uses connections (evidence: `packages/async-storage/src/web-module/IndexedDBStorage.ts`)
- Native bridge → Android module: calls
- Android module → Android registry: dispatches (evidence: `packages/async-storage/android/src/main/kotlin/org/asyncstorage/legacy_storage/LegacyStorageModule.kt`)
- Android registry → Android adapter: selects (evidence: `packages/async-storage/android/src/main/kotlin/org/asyncstorage/storage/StorageRegistry.kt`)
- Android adapter → Shared storage API: calls (evidence: `packages/async-storage/android/src/main/kotlin/org/asyncstorage/storage/RNStorage.kt`)
- Native bridge → Apple adapter: calls
- Apple adapter → Shared storage API: calls (evidence: `packages/async-storage/apple/storage/RNStorage.swift`)
- Apple registry → Apple adapter: registers (evidence: `packages/async-storage/apple/storage/StorageRegistry.swift`)
- Shared storage API → Storage implementation: implemented by (evidence: `shared-storage/src/commonMain/kotlin/org/asyncstorage/shared_storage/SharedStorageImpl.kt`)
- Storage implementation → Room database: queries (evidence: `shared-storage/src/commonMain/kotlin/org/asyncstorage/shared_storage/SharedStorageImpl.kt`)
- Android database setup → Storage implementation: constructs (evidence: `shared-storage/src/androidMain/kotlin/org/asyncstorage/shared_storage/SharedStorage.android.kt`)
- Android database setup → Room database: opens (evidence: `shared-storage/src/androidMain/kotlin/org/asyncstorage/shared_storage/SharedStorage.android.kt`)
- Apple database setup → Storage implementation: constructs (evidence: `shared-storage/src/appleMain/kotlin/org/asyncstorage/shared_storage/SharedStorage.apple.kt`)
- Apple database setup → Room database: opens (evidence: `shared-storage/src/appleMain/kotlin/org/asyncstorage/shared_storage/SharedStorage.apple.kt`)
- React Native app → Windows fallback: uses on Windows (evidence: `README.md`)
- Windows fallback → Windows SQLite: calls legacy module
