Edit in GitHubLog an issue

Storages

Sometimes, you may want to simply store a key-value pair and use it later with a quick lookup mechanism. For such situations, Storages offer you an easy way.

UXP supports three types of storages Session Storage, Local Storage and Secure Storage. The APIs for all three look very similar, but you should choose the right storage based on your use case.

Session Storage keeps data only valid up to a session.

  • In plugins, a session lasts from 'Load' to 'Unload' of the plugin when managed from UDT. If installed, it lasts from the launch till the quit of the application.
  • In scripts, every execution is considered a separate session.

To store the data for an extended period choose from Local storage and Secure storage. Secure Storage is apt for storing sensitive information such as passwords.

Copied to your clipboard
// Session storage
const storage = window.sessionStorage;
Copied to your clipboard
// Local storage
const storage = window.localStorage;
Copied to your clipboard
// Secure storage
const storage = require('uxp').storage.secureStorage;

Once you have decided on the right storage for you, save and retrieve key-value pair with ease.

Copied to your clipboard
await storage.setItem('key', 'value');
await storage.getItem('key');

Reference material

  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.