Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Default to local storage #1776

Closed
chasefleming opened this issue Sep 6, 2023 · 4 comments · Fixed by #1782
Closed

[FEATURE] Default to local storage #1776

chasefleming opened this issue Sep 6, 2023 · 4 comments · Fixed by #1782
Labels

Comments

@chasefleming
Copy link
Member

Issue to be solved

Because FCL uses session storage instead of local storage for storing the current user every time you open a new tab in your browser or your mobile browser you have to re-authenticate. This bumps some road bumps in the UX. I know this decision was originally made for security reasons, but after seeing the UX challenges I think it's time to revisit this topic and see if there is a way to make local storage the default option.

Suggest A Solution

No response

What are you currently working on that this is blocking?

No response

@bluesign
Copy link

bluesign commented Sep 7, 2023

I totally agree, last time I checked also storage strategies were not exported. Exporting them also can be very nice. So people can just set via config easily.

@nialexsan
Copy link
Contributor

nialexsan commented Sep 14, 2023

by design fcl storage can be set up to use custom implementation like this:

const isServerSide = () => typeof window === "undefined"

const getLocalStorage = () => {
  try {
    const LOCAL_STORAGE = {
      can: !isServerSide(),
      get: async key => JSON.parse(localStorage.getItem(key)),
      put: async (key, value) => localStorage.setItem(key, JSON.stringify(value)),
    }
    return LOCAL_STORAGE
  } catch (error) {
    return null
  }
}

...

config.put("fcl.storage.default", getLocalStorage())

@bluesign
Copy link

bluesign commented Sep 14, 2023

Is there a specific reason we don't expose them as alternatives?

‘config.put("fcl.storage.default",fcl.SESSION_STORAGE) ‘ etc

@chasefleming
Copy link
Member Author

Yeah @bluesign I like that idea. We could just have what @nialexsan mentioned as options to set for the most common.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants