Storage
Using Storage
SDK object: Storage
Storage You can use native storage with Storage. If you delete the Toss app, the data stored in storage will also be deleted.
Signature
Storage: {
getItem: typeof getItem;
setItem: typeof setItem;
removeItem: typeof removeItem;
clearItems: typeof clearItems;
}Properties
getItemtypeof getItem
This function retrieves a value from local storage.
setItemtypeof setItem
This function stores a value in local storage.
removeItemtypeof removeItem
This function deletes a value from local storage.
clearItemstypeof clearItems
This function deletes all data from local storage.
Try the sample app
apps-in-toss-examples from the repository with-storage Download the code, or scan the QR code below to try it yourself.
QR code link: intoss://with-storage
Save a value
SDK function: setItem
setItem The function stores string data in local storage. Use it when data should persist even after closing and reopening the app.
Signature
Parameters
key · Required ·
stringEnter the key of the item to store.
value · Required ·
stringEnter the value of the item to store.
Return value
Promise<void>If the item is stored successfully, nothing is returned.
Example
my-keyStore an item in
Get a value
SDK function: getItem
getItem The function retrieves string data stored in local storage.
Signature
Parameters
key · Required ·
stringEnter the key of the item to retrieve.
Return value
Promise<string | null>Returns the string value stored under the specified key. If there is no value,
nullreturns null.
Example
my-keyRetrieve the item stored in
Delete a value
SDK function: removeItem
removeItem The function deletes the value corresponding to a specific key.
Signature
Parameters
key · Required ·
stringEnter the key of the item to delete.
Return value
Promise<void>If the item is deleted, nothing is returned.
Example
my-keyDelete the item stored in
Reset storage
SDK function: clearItems
clearItems The function deletes all data stored in local storage.
Signature
Return value
Promise<void>When items are deleted, nothing is returned and the storage is reset.
Example
Reset storage
Web standard storage and cache behavior
localStorage, IndexedDB, window.caches Web standard storage is stored based on the web view's origin (URL).
Since the Toss app release environment and the QR code test environment use different URLs, data stored in web standard storage is not shared between them.
Toss app release:
https://<appName>.apps.tossmini.comQR code test:
https://<appName>.private-apps.tossmini.com
QR code test ↔ Toss app release
Not shared
QR test — version A ↔ version B
Shared
Toss app release — previous version ↔ new version
Shared
Frequently asked questions
Last updated
Was this helpful?