Category: How do I do X?

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

How to use the JS editor to get sessionStorage and localStorage?


I am trying to access the sessionStorage and localStorage provided by others through the JS editor, but I am getting an error saying "sessionStorage is not defined". I have tried using, but it only gets the keys and values I provided myself. I need help finding a solution to access these storage objects.


Unfortunately, it is not currently possible to access the window object in Appsmith JS editor, which means that accessing sessionStorage and localStorage is not possible. One workaround could be to pass the data as query parameters and access them using {{appsmith.URL.queryParams}}. However, it's important to consider the security risks of passing sensitive data through query parameters.

In terms of the provided example, the error "UncaughtPromiseRejection: sessionStorage is not defined" occurs because sessionStorage is not accessible in the Appsmith JS editor. Therefore, the code cannot retrieve the "test123" key from sessionStorage.

As a potential solution, it would be helpful to understand the specific use case for needing to access sessionStorage. This information can be shared in the Github issue linked above to help inform future platform development.