Page updated Jan 16, 2024

Additional DataStore methods

Clear

To clear local data from DataStore, use the clear method:

1import { DataStore } from 'aws-amplify/datastore';
2
3await DataStore.clear();

If your app has authentication implemented, it is recommended to call DataStore.clear() on sign-in/sign-out to remove any user-specific data. This method is often important to use for shared device scenarios or where you need to purge the local on-device storage of records for security/privacy concerns.

Start

To manually start the sync process, use the start method:

1import { DataStore } from 'aws-amplify/datastore';
2
3await DataStore.start();

Synchronization starts automatically whenever you run any of the following methods: DataStore.query(), DataStore.save(), DataStore.delete(), or DataStore.observe().