UseGetStorage
katanakit-js / useGetStorage
Function: useGetStorage()
Section titled “Function: useGetStorage()”function useGetStorage<T>(key, target?): T | null;Defined in: infrastructure/storage/storage.service.ts:351
Retrieves a value from storage by key.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type | Description |
|---|---|---|
T |
unknown |
Expected value type. |
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
key |
string |
undefined |
The storage key. |
target? |
"localStorage" | "sessionStorage" |
"localStorage" |
Which storage backend to use (default: "localStorage"). |
Returns
Section titled “Returns”T | null
The deserialized value, or null if not found.
Example
Section titled “Example”const token = useGetStorage<string>("auth_token");const session = useGetStorage<SessionData>("session", "sessionStorage");