@hotosm/hanko-auth 0.4.8 → 0.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -0
- package/dist/hanko-auth.esm.js +1255 -1241
- package/dist/hanko-auth.iife.js +47 -40
- package/dist/hanko-auth.umd.js +46 -39
- package/package.json +3 -2
- package/src/hanko-auth.styles.ts +8 -1
- package/src/hanko-auth.ts +24 -4
package/README.md
CHANGED
|
@@ -127,6 +127,26 @@ auth.addEventListener("logout", () => {
|
|
|
127
127
|
});
|
|
128
128
|
```
|
|
129
129
|
|
|
130
|
+
## Flash Prevention (localStorage cache)
|
|
131
|
+
|
|
132
|
+
On remount (e.g. React navigation), the component checks `localStorage` for a cached user under the key `hotosm-auth-user`. If found, it skips the loading spinner and renders immediately with the cached user.
|
|
133
|
+
|
|
134
|
+
The component reads from this key but does not write to it. The host app is responsible for keeping it in sync:
|
|
135
|
+
|
|
136
|
+
```js
|
|
137
|
+
// Write on login
|
|
138
|
+
auth.addEventListener("hanko-login", (e) => {
|
|
139
|
+
localStorage.setItem("hotosm-auth-user", JSON.stringify(e.detail.user));
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// Clear on logout
|
|
143
|
+
auth.addEventListener("logout", () => {
|
|
144
|
+
localStorage.removeItem("hotosm-auth-user");
|
|
145
|
+
});
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
If the key is absent (first visit, after logout, or cleared storage), the component falls back to its normal loading flow — no change in behavior.
|
|
149
|
+
|
|
130
150
|
## Usage Modes
|
|
131
151
|
|
|
132
152
|
### Header Mode (default)
|