localstorage exception

I'm working on a page in a browser that doesn't have localStorage. As such, I've attempted to disable it with the 'persistSession' option, but failed - it still seems to attempt to access globalThis.localStorage causing an exception. The only way I managed to make it work is by faking a localStorage API in an object which I assign to the `localStorage' option. I feel like this is not ideal and likely to lead to problems down the line.
Is there a way to stop it using localStorage, or is localStorage required?
Was this page helpful?