Skip to content

useCookies

Hook that manages cookie values

state
medium
test coverage
Last changed: 6 months ago

Installation

Library
CLI
Manual
typescript
import { useCookies } from '@siberiacancode/reactuse';

Usage

typescript
const { value, set, remove, getAll, clear } = useCookies();
## Demo

Api

Returns

UseCookieReturn<Value>

Type declaration

typescript
import type { RemoveCookieParams, SetCookieParams } from '../useCookie/useCookie';

export type CookieParams = Record<string, any>;

export interface UseCookiesOptions<Value> {
  /* The deserializer function to be invoked */
  deserializer?: (value: string) => Value[keyof Value];
  /* The serializer function to be invoked */
  serializer?: (value: Value[keyof Value]) => string;
}

Source

SourceDemo

Contributors

D
debabin
debabin
B
babin
babin

Released under the MIT License.