To answer your exact question
As shown in pull the request that you linked , you can now specify Storage for the pool. There are two built-in storage objects according to MDN: localStorage and sessionStorage . You can use sessionStorage as is (I have not tried it yet). It will save the page reload, but will be cleared when the page / tab is closed. New tabs get a new sessionStorage object.
let pool = new CognitoUserPool({ UserPoolId, ClientId, storage: window.sessionStorage });
If this does not work, you will need to create an object that implements the Storage API. It is quite simple and does not take much time. There are 5 general methods, and most of them can be matched 1: 1 with a simple Object
Storage.key(int n); // Return the Nth key Storage.getItem(string key) // return the value for given key Storage.setItem(string key, string value) // store a value at key Storage.removeItem(string key) // remove the value for key Storage.clear() // delete all values
Here is the NPM package that implements the Storage API in memory . The downside is that refreshing the page will clear it.
As you can see from the source code , this is not very difficult.
but
In my opinion, the best alternative would be to use a very simple server, such as serve or the Web server for Chrome , to serve files via http so that localStorage (and many other parts of the page) work as you would expect.
source share