Any reasons why `window.localStorage` would be `null`?

I’m trying to access window.localStorage but it is coming out as null.
I’m running in the Debug mode with the Webview sample from the documentation.

These are the versions I’m using:

      "dependencies": {
        "@amazon-devices/react-native-kepler": "^2.0.0",
        "@amazon-devices/webview": "^3.3.1769932800",
        "react": "18.2.0",
        "react-native": "0.72.0"
      },

While inspecting I can clearly see that window.localStorage is null:
image

Hello @adheus ,
Thank you for your question regarding the issue you are facing.
Our team is looking into this, we will get back to you once we have an update.

Regards,
Gio VM

Hi @adheus ,
Thanks for sharing the details and for reaching out!
The window.localStorage (and also sessionStorage / related Web Storage APIs) return null in the Vega WebView when DOM storage isn’t enabled. Once domStorageEnabled is set, both localStorage and sessionStorage will work as expected.
For reference, you can find this in the tech docs here: domStorageEnabled

From the Vega Tech Docs:
<WebView
source={{ uri: ‘``https://amazon.com``’ }}
domStorageEnabled={true}
/>

Hope that helps! Let us know if you still run into any issues after enabling DOM storage.

Regards,
Giovanni VM

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.