Skip to main content


The storeValue() function stores the data in the browser's local storage as key-value pairs that represent storage objects and can be later accessed anywhere in the application.

Using the StoreValue Function


storeValue(key: string, value: any, persist? = true): Promise



A string containing the key name that acts as a unique identifier to access the associated value.


The data you want to save using storeValue(). You can save any data type in the Appsmith store.


Accepts a boolean value. The default value is true, which ensures the persistence of the key-value pair in the browser's local storage, allowing it to be used between sessions. Setting it to false prevents the value from persisting, and the key gets removed when the page is refreshed or closed.

Example 1:

If you want to store the text of an input widget, you can use storeValue() as shown below:


Here, email is the key where the value is stored, and input1.text is the value in the input widget that's saved in the storage object.

Example 2:

You can save any data type with storeValue(). The code snippet below shows how to store employees' basic information using a function inside a JS Object.

export default {
writeToStore: () => {
storeValue("isActive", true) // Boolean
storeValue("name", "Robert") // String
storeValue("pin", 9929) // Number


Access stored value

You can access the values from the store by referencing the key inside the store object.


{{ }}


If you have stored a value with the key email, you can access this value anywhere in the application using the code snippet given below:


Modify value

You can update the saved value in the store, by overwriting the data using its key.


If you have stored a boolean value with the key isActive, you can update the boolean value from True to False using a JS Object as shown below:

export default {
updateStore: () => {
if( === true)
storeValue("isActive", false)

Store multiple values

If you need to store many values, instead of making multiple calls to the storeValue() function, it's recommended to use an object array to store the values. All values can be assigned in a single storeValue() function as shown below:

//employee data
storeValue("user", { "name": "Bar Crouch", "email": "", "pin": "9984"})

The below example shows how to access the name of the employee that you have stored:

//Access store using a JSobject
export default {
userName: () => {
let user =
return user
//Text binding


You can update the saved employee data in the storage as shown below:

//updating employee data
export default {
complexUpdate: () => {
let user = // { "name": "Bar Crouch", "email": ""} = "" = "Bangalore"
storeValue("user", user)

Storage states

Appsmith’s storeValue() function consists of two storage states: persistent and session state.

Persistent state

If you store value in the persistent state, it remains in the store across different sessions/pages and value is saved even if the page is reloaded. By default, the persist argument is set to true in storeValue() and so the data is saved in a persistent state.


If you don't define the value for persist argument, the value is saved in the persistent state by default.


The persistent state is cleared out when the user logs out.

Session state

You can use the session state to store the value you wish to hold until the page reloads or a user closes the window. To save data in this way, add false to the persist argument in the storeValue() function.

{{storeValue('two',Input2.text, false)}}

Session state (persist=false) is only available till the user exits the app or refreshes a page.


If the same key is available in the session and persisted states, the session value gets a preference.

Check the sample app to learn more about persistent and session states.

Asynchronous behavior of store value

storeValue() is asynchronous, so its execution isn't dependent on another function or task. To handle this scenario, you'll have to use async/await to control the execution.


Suppose there is a JS function that calls an API that returns a unique identifier, and you want to save the value returned using storeValue().

export default {
getUniqueValue: () => {
showAlert("Success! Store value set: " +;

When you run the function, you expect an alert success message with the value stored in the key uniqueEmail but it shows undefined. As storeValue() is asynchronous, it may execute while the API call is in progress and the value isn't saved in the storage resulting in undefined value.

To handle such a scenario, you can use async/await to ensure that the storeValue() function waits for the API call to complete execution. Example:

Modify the code to use async/await as shown below:

export default {
getUniqueValue: async () => {
await storeValue("uniqueEmail",;
showAlert("Success, Store value set: " +;

The getUniqueValue function calls to fetch data from the API. The prefix await to the GetUniqueNameAPI call ensures that the control waits for API execution to complete and then moves to the following line. The prefix await to the storeValue() ensures that the value gets added to the store for the given key before executing showAlert in the next line.

See also