UNPKG

@thibault.sh/hooks

Version:

A comprehensive collection of React hooks for browser storage, UI interactions, and more

28 lines (26 loc) 978 B
/** * Options for configuring cookie behavior */ interface CookieOptions { /** Number of days until the cookie expires (default: 7) */ days?: number; /** Cookie path (default: "/") */ path?: string; /** Cookie domain */ domain?: string; /** Whether the cookie requires HTTPS (default: false) */ secure?: boolean; /** SameSite cookie attribute (default: "Lax") */ sameSite?: "Strict" | "Lax" | "None"; } /** * Hook for managing state persisted in a browser cookie * @param name - The name of the cookie * @param initialValue - The initial value to use if no cookie exists * @returns A tuple containing: * - The current cookie value (or null if not set) * - A function to update the cookie value and its options * - A function to delete the cookie */ declare function useCookieState(name: string, initialValue: string): [string | null, (newValue: string, options?: CookieOptions) => void, () => void]; export { useCookieState };