Skip to main content
Version: 3.x

Taro.getStorageSync(key)

The synchronous version of Taro.getStorage.

Reference

Type

(key: string) => any

Parameters

PropertyTypeDescription
keystringThe specified key in the local cache

Sample Code

Taro.getStorage({
key: 'key',
success: function (res) {
console.log(res.data)
}
})
try {
var value = Taro.getStorageSync('key')
if (value) {
// Do something with return value
}
} catch (e) {
// Do something when catch error
}

API Support

APIWeChat Mini-ProgramH5React Native
Taro.getStorageSync✔️✔️