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
fix: namespace storage key #460
Conversation
Great work! However, this could make the storage key a guessing game as its being inferred and as such might introduce a breaking change for unaware users (pulling from localStorage manually with the default key currently used). createClient(URL, KEY, {
// Options
storageKey: "myproject-sb" // or authStorageKey: "..."
}) |
hey @sannajammeh, it wouldn't be a guessing game because the developer would know what the storage key is based on the project-ref from the supabase url provider when the client is initialised |
Hi @kangmingtay My reasoning is it will unknowingly create a guessing game. I would know because I've read this PR and read through the changelogs, but someone for instance blindly doing a pnpm update would not. Let's say Release x.1 contains the current behavior of a single key. I pull from local-storage manually for various reasons. I update the library to x.2 and all of a sudden the app breaks due to the local-storage key changing (even though I'm only using a single instance of SB). If I haven't read the changelogs I wouldn't know the real reason my app is breaking is actually that the local-storage key has changed. The cookie options allows for custom key's decided on by the developer. Therefore my take on it is the developer running multiple instances should be the one responsible for managing conflicts between them (same how the current sdk uses cookie name). Allow a custom This is obviously just a suggestion and the example I'm providing is an edge case. Either solution is ultimately positive! |
To me that PR looks good. But - as @sannajammeh says - it is a breaking change. Strictly following semver, this PR would require the release of supabase-js v2.0.0 (breaking change -> new major). Until v2.0.0 supabase/auth-js#361 could be partially fixed by letting consumers pass in a custom storageKey to This current PR could always be added in next major and serve as a default, when there is no storageKey set in the Also an update to a version containing this PR would log out every user session as soon as users get the new code (new key !== old key). And there would eventually also be garbage sessions left in storage under the old key. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🔥
Hey @pixtron and @sannajammeh, thanks for the feedback! I've made the necessary changes so you'll be able to pass in a custom storage key in the next major version release. |
What kind of change does this PR introduce?