# @aws-amplify/datastore

> AppSyncLocal support for aws-amplify

Latest version **5.1.12** (published 2026-09-21) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @aws-amplify/datastore
pnpm add @aws-amplify/datastore
yarn add @aws-amplify/datastore
bun add @aws-amplify/datastore
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 5.1.12 |
| Published | 2026-09-21 |
| First published | 2019-12-03 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 7 |
| Unpacked size | 2.7 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9560 |
| Author | Amazon Web Services |
| Maintainers | amzn-oss, aws-amplify-ops, amplify-studio-uibuilder, amplify-codegen, amplify-data-dev-npm, aws-amplify-data-runtime |

## Links

- npm: https://www.npmjs.com/package/@aws-amplify/datastore
- Repository: https://github.com/aws-amplify/amplify-js
- Homepage: https://docs.amplify.aws/
- Issues: https://github.com/aws/aws-amplify/issues
- npm.io page: https://npm.io/package/@aws-amplify/datastore

## Dependencies (7)

- [idb](https://npm.io/package/idb.md) 5.0.6
- [rxjs](https://npm.io/package/rxjs.md) ^7.8.1
- [ulid](https://npm.io/package/ulid.md) ^2.3.0
- [immer](https://npm.io/package/immer.md) ^11.1.9
- [buffer](https://npm.io/package/buffer.md) 4.9.2
- [@aws-amplify/api](https://npm.io/package/@aws-amplify/api.md) 6.4.1
- [@aws-amplify/api-graphql](https://npm.io/package/@aws-amplify/api-graphql.md) 4.10.0

## Recent versions

- 5.1.12 (latest) — 2026-09-21
- 5.1.13-unstable-5aaad5c-20260921082418 (unstable) — 2026-09-21
- 4.7.29 (stable-5) — 2026-09-02
- 5.1.9-connect-customer-profiles-push-2eff5ec-20260722141620 (connect-customer-profiles-push) — 2026-07-22
- 5.1.5-coolfeature-28752fd-20260202121056 (coolfeature) — 2026-02-02
- 5.1.5-mypreid-c2c4292-20260202114045 (mypreid) — 2026-02-02
- 5.1.5-mypreid.0aaa467.0 (mypreid.0aaa467) — 2026-02-02
- 0.0.0-changesets-preid-f620002-20260129130740 (changesets-preid) — 2026-01-29
- 0.0.0-unstable-1ca644b-20260128091132 (unstable-test) — 2026-01-28
- 5.1.3-context-cogs.077566e.0 (context-cogs) — 2026-01-12
- 5.0.83-local-stack.00864ae.0 (local-stack) — 2025-05-14
- 5.0.82-poc-start-after.e717946.0 (poc-start-after) — 2025-04-23
- 5.0.82-rn-exports.f28cd66.0 (rn-exports) — 2025-04-23
- 5.0.53-email-mfa-test.b78433a.0 (email-mfa-test) — 2025-04-05
- 5.0.75-Lerna-v8-testing.5bbeffa.0 (Lerna-v8-testing) — 2025-03-07
- … 2084 more at https://npm.io/package/@aws-amplify/datastore/versions

## README

> INTERNAL USE ONLY

This package contains the AWS Amplify DataStore category and is intended for internal use only. To integrate Amplify into your app, please use [aws-amplify](https://www.npmjs.com/package/aws-amplify).

# AWS Amplify DataStore Docs

[Amplify DataStore](https://docs.amplify.aws/lib/datastore/getting-started/q/platform/js/) provides a programming model for leveraging shared and distributed data without writing additional code for offline and online scenarios, which makes working with distributed, cross-user data just as simple as working with local-only data.

---

| package                | version                                                         | open issues                                                                                                                                                                                  | closed issues                                                                                                                                                                                 |
| ---------------------- | --------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| @aws-amplify/datastore | ![npm](https://img.shields.io/npm/v/@aws-amplify/datastore.svg) | [![Open Issues](https://img.shields.io/github/issues/aws-amplify/amplify-js/DataStore?color=red)](https://github.com/aws-amplify/amplify-js/issues?q=is%3Aissue+label%3ADataStore+is%3Aopen) | [![Closed Issues](https://img.shields.io/github/issues-closed/aws-amplify/amplify-js/DataStore)](https://github.com/aws-amplify/amplify-js/issues?q=is%3Aissue+label%3ADataStore+is%3Aclosed) |

---

## **👋 Note For Contributers: 👋**

_**Please update these docs any time you find something that is incorrect or lacking. In particular, if a line in the docs prompts a question, take a moment to figure out the answer, then update the docs with the necessary detail.**_

---

## Getting Started

Before you start reading through these docs, take a moment to understand [how DataStore works at a high level](https://docs.amplify.aws/lib/datastore/how-it-works/q/platform/js/). Additionally, we recommend first reading through [docs.amplify.aws](https://docs.amplify.aws/lib/datastore/getting-started/q/platform/js/). The purpose of these docs is to dive deep into the codebase itself and understand the inner workings of DataStore for the purpose of contributing. Understanding these docs is **not** necessary for using DataStore. Lastly, before reading, take a look at [the diagrams below](#diagrams).

---

## Docs

- [Conflict Resolution](docs/conflict-resolution.md)
- [Contributing](docs/contributing.md)
- [DataStore Lifecycle Events ("Start", "Stop", "Clear")](docs/datastore-lifecycle-events.md)
  - This explains how DataStore fundementally works, and is a great place to start.
- [Getting Started](docs/getting-started.md) (Running against a sample app, etc.)
- [Namespaces](docs/namespaces.md)
- [How DataStore uses Observables](docs/observables.md)
- [Schema Changes](docs/schema-changes.md)
- [Storage](docs/storage.md)
- [Sync Engine](docs/sync-engine.md)
- ["Unsupported hacks" / workarounds](docs/workarounds.md)

---

# Diagrams

_Note: relationships with dotted lines are explained more in a separate diagram._

## How the DataStore API and Storage Engine Interact

```mermaid
flowchart TD
  %% API and Storage
  api[[DS API]]-- observe -->storage{Storage Engine}
  storage-- next -->adapter[[Adapter]]
  adapter-->db[[Local DB]]
  db-->api
  sync[[Sync Engine*]]-.-storage
  sync-.-appSync[(AppSync)]
```

# How the Sync Engine Observes Changes in Storage and AppSync

_Note: All green nodes belong to the Sync Engine._

\* Merger first checks outbox

\*\* Outbox sends outgoing messages to AppSync

```mermaid
flowchart TD

  subgraph SyncEngine
  index{index.ts}-- observe -->reach[Core reachability]

  subgraph processors
  mp[Mutation Processor]
  sp[Subscription Processor]
  syp[Sync Processor]
  end

  reach--next-->mp[Mutation Processor]
  reach--next-->sp[Subscription Processor]
  reach--next-->syp[Sync Processor]

  subgraph outbox / merger
  outbox[Outbox]
  merger[Merger]
  outbox---merger
  end

  end

  api[DS API]-.->storage
  mp-- 1. observe -->storage{Storage Engine}
  storage-- 2. next -->merger[merger*]-- next -->storage


  sp-- observe -->appsync[(AppSync)]
  appsync-- next -->sp

  syp---appsync

  mp-->outbox[outbox**]

  appsync<--->outbox
  %% styling
  classDef syncEngineClass fill:#8FB,stroke:#333,stroke-width:4px,color:#333;
  class index,mp,sp,syp,merger,outbox syncEngineClass;
```

---

# Project Structure

<pre>
amplify-js/packages/datastore/src
├── authModeStrategies
│   └── defaultAuthStraegy.ts
│   └── index.ts
│   └── multiAuthStrategy.ts
├── datastore
│   └── datastore.ts # Entry point for DataStore
├── predicates
│   └── index.ts
│   └── sort.ts
├── ssr
├── storage # Storage Engine
│   └── adapter # Platform-specific Storage Adapters
│      └── getDefaultAdapter
│      └── AsyncStorageAdapter.ts
│      └── AsyncStorageDatabase.ts
│      └── index.ts
│      └── IndexedDBAdapter.ts
│      └── InMemoryStore.native.ts
│      └── InMemoryStore.ts
│   └── storage.ts # Entry point for Storage
├── sync # Sync Engine
│   └── dataStoreReachability
│      └── index.native.ts
│      └── index.ts
│   └── processors # Sync Engine Processors
│      └── mutation.ts
│      └── subscription.ts
│      └── sync.ts
│   └── datastoreConnectivity.ts # Subscribe to reachability monitor
│   └── index.ts # Entry point for Sync Engine
│   └── merger.ts # <a href="https://github.com/aws-amplify/amplify-js/blob/datastore-docs/packages/datastore/docs/sync-engine.md#merger" title="merger doc">doc</a>
│   └── outbox.ts # <a href="https://github.com/aws-amplify/amplify-js/blob/datastore-docs/packages/datastore/docs/sync-engine.md#outbox" title="outbox doc">doc</a>
</pre>

---

## Other Resources:

- [High-level overview of how DataStore works](https://docs.amplify.aws/lib/datastore/how-it-works/q/platform/js/)
- [DataStore Docs](https://docs.amplify.aws/lib/datastore/getting-started/q/platform/js/)
- [re:Invent talk](https://www.youtube.com/watch?v=KcYl6_We0EU)

---
_Source: https://npm.io/package/@aws-amplify/datastore · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
