Use store for UserLogin

Good morning,

I would like to use the “Store” function for the user login instead of the localStorage, but I see that when I refresh the page the store is reset. Is there any way to fix it or do you have any advice?

App target:

  • Web

  • Cordova (Android/IOS)


on click button login:

        method: 'POST',
        url: page,
        crossDomain: true,
        dataType: 'json',
        data: obj,
        success: function (data) {
  'updateUser', data);
            app.views.main.router.navigate(`/`, {reloadCurrent: true});            


import { createStore } from 'framework7';

const store = createStore({
    state: {
        user: null,
    actions: {
        updateUser( { state }, userData) {
            state.user = userData || null;
export default store;

For now the only option that came to my mind is to use this plugin saving and encrypting the localStorage then using the store when starting the app, if you have better ways thank you for the help

You can use store to dispatch actions, and retrieve data but you need to store session data somewhere like in localStorage/cookie. Encryption on the front end is not 100% secure as mentioned on that plugin page. But yes, that’s a good option if you want to encrypt.

1 Like