supermemory/packages/hooks/use-local-storage-username.ts
2026-04-02 18:20:34 +00:00

19 lines
455 B
TypeScript

import * as React from "react"
/**
* `username` / `userName` keys written by the app. Populated only after mount so
* server HTML and the first client render stay aligned (no hydration mismatch).
*/
export function useLocalStorageUsername(): string {
const [value, setValue] = React.useState("")
React.useEffect(() => {
setValue(
localStorage.getItem("username") ??
localStorage.getItem("userName") ??
"",
)
}, [])
return value
}