Skip to main content
Use this API to store data with a specified key in local cache. Overwrites existing data with the same key.

Parameters

PropertyTypeRequiredDescription
keyStringYesStorage key identifier
dataObject/StringYesData to store
successFunctionNoCallback on success
failFunctionNoCallback on failure
completeFunctionNoCallback that always executes

Limits

  • Single data item: max 200KB
  • Total storage per Mini Program: max 10MB

Code Example

my.setStorage({
  key: 'userSettings',
  data: { theme: 'dark', language: 'en' },
  success: () => {
    console.log('Data saved');
  }
});

my.getStorage

Get stored data

my.setStorageSync

Store data synchronously