-
Notifications
You must be signed in to change notification settings - Fork 867
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
How can we modify the keyPrefix
#137
Comments
Ok, answering my own questions, you actually can do that in your application before you configure your store require('redux-persist/constants').keyPrefix = 'something_else'; And your key will be changed. |
Why do you want to change the key prefix? I think this will be a very rare use case, and your solution works. |
One common use case is to store (non-sensitive) data for multiple users of the app. I would use a user ID as the key prefix. Another is to serve multiple Redux apps on a single domain, with their persisted state namespaced. I think it's important to have a first-class API for this. |
+1 for this feature as well. Ideally you wouldn't set this globally but could set it on store creation (perhaps as input to a store enhancer?). My specific use case is in my app I create multiple redux stores for managing state (a single global store for db/auth state + local component stores for ui state). I'm only persisting global state at the moment but I could see adding the ability to persist certain parts of ui state as well. Strictly for aesthetics, it would also be nice to just remove the prefix altogether. I'm using redux-persist in a chrome packaged app and wrote a small storage adapter to persist to chrome.storage.local where the key prefix isn't really necessary. This is definitely a minor nit-pick. That's my 2 cents, thanks for the great lib regardless! |
thanks for the input, sounds like we definitely need configurable keyPrefix :) This would be trivial to implement as a config option |
❤️ |
I will cut a release soon, hopefully tomorrow 👍 |
It would be great to mention this in the docs. |
👍 But is that mentioned in the doc ? |
It would be good to add this to the config options in the docs. PR appreciated! |
Very useful indeed. |
Currently the keyPrefix is hardcoded as constant, would that be a good feature if people can overwrite it ??
https://github.com/rt2zz/redux-persist/search?utf8=%E2%9C%93&q=keyPrefix
The text was updated successfully, but these errors were encountered: