Using local storage instead of session storage in Blazor WASM app

We’re moving from Azure B2C to Auth0 in our Blazor WASM app (following this article to get it working).

This works, but because it defaults to using session storage for the tokens, if the user opens a new browser tab, they need to authenticate.

We want to switch to local storage, which is what we’re using in B2C.

Reading this GitHub issue, it looks like it’s not possible? (well, not without a pretty horrendous hack)

Is this correct? It’s not a great user-experience having to sign in again every time the user opens a new tab.

Thanks for your help,
Dan

Hi @danclarke-smve,

Thank you for posting your question on our community page.

Personally, I would not solely rely on that github post when it comes to your particular use case because it might be a little outdated. From the research that i have done around this you should also be able to use the Blazored LocalStorage Library that will provide access to localstorage within your application. You can check it out using this link on github.

This way you can set the cacheLocation: 'localstorage' paramater in your implementation. Additionally you can also configure your integration with Refresh Token Rotation in order to prevent possible re-authentication issues.

I hope this helped and if you have additional questions please do no hesitate to ask.
Thanks,
Remus

Hi @remus.ivan - It’s not my code that’s interacting with the browser storage though, so I can’t just swap out for a different storage library. It’s the OIDC library that’s interacting with it.