---
title: Storing data
description: >-
  The Minis platform provides a few different ways to store data associated with
  a user.
source_url:
  html: 'https://shopify.dev/docs/api/shop-minis/storing-data'
  md: 'https://shopify.dev/docs/api/shop-minis/storing-data.md'
api_name: shop-minis
---

# Storing data

The Minis platform provides a few different ways to store data associated with a user. This guide will walk you through the different options and when to use each.

***

## Async storage

The `useAsyncStorage` hook provides a way to store data in the device's local storage. It's a simple and easy way to store data that persists across sessions, but it will be deleted if the user uninstalls the Shop app.

[Hook - Learn more about the useAsyncStorage hook](https://shopify.dev/docs/api/shop-minis/hooks/storage/useasyncstorage)

## Using async storage

```tsx
import {useEffect} from 'react'


import {useAsyncStorage} from '@shopify/shop-minis-react'


export default function MyComponent() {
  const {getItem, setItem, removeItem, getAllKeys, clear} = useAsyncStorage()


  useEffect(() => {
    async function handleStorageOperations() {
      // Get an item from storage
      const value = await getItem({key: 'myKey'})
      console.log({value})


      // Set an item in storage
      await setItem({key: 'myKey', value: 'Hello, World!'})


      // Remove an item from storage
      await removeItem({key: 'myKey'})


      // Get all keys in storage
      const keys = await getAllKeys()
      console.log({keys})


      // Clear all items from storage
      await clear()
    }


    handleStorageOperations()
  }, [getItem, removeItem, setItem, getAllKeys, clear])
}
```

***

## Secure storage

The `useSecureStorage` hook provides a way to store credentials and other sensitive data in the device's secure storage. It's a more secure way to store data that persists across sessions, but it will be deleted if the user uninstalls the Shop app.

[Hook - Learn more about the useSecureStorage hook](https://shopify.dev/docs/api/shop-minis/hooks/storage/usesecurestorage)

## Using secure storage

```tsx
import {useEffect} from 'react'


import {useSecureStorage} from '@shopify/shop-minis-react'


export default function MyComponent() {
  const {getSecret, setSecret, removeSecret} = useSecureStorage()


  useEffect(() => {
    async function handleSecureStorageOperations() {
      // Get a secret from secure storage
      const secret = await getSecret()
      console.log({secret})


      // Set a secret in secure storage
      await setSecret({value: 'Sensitive Data'})


      // Remove a secret from secure storage
      await removeSecret()
    }


    handleSecureStorageOperations()
  }, [getSecret, setSecret, removeSecret])
}
```

***
