Installation
npx sse-hooks add use-cookie
yarn dlx sse-hooks add use-cookie
pnpm dlx sse-hooks add use-cookie
deno run -A npm:sse-hooks add use-cookie
bunx sse-hooks add use-cookie
Usage
import { useCookie } from "./{hooks file}";
// Creates a cookie named "__Secure-token"
const [token, setToken] = useCookie("token", "", {
prefix: "__Secure-",
secure: true,
});
API
Parameters
| Prop | Default | Type |
|---|---|---|
options |
|
Options for customization.
|
key | - |
The base name of the cookie. |
initialValue | - |
The initial value of the state. |
Returns
| Return Value | Default | Type |
|---|---|---|
[0] | - |
|
[1] | - |
|
[2] | - |
|
Types Aliases
Changelog
81e9f — feat: update documentation and categorize hooks
c165d — feat: enhance useRoleGuard and useSSR hooks with additional options and documentation
30da4 — feat: add new hooks and their metadata
cf13e — feat: add custom hooks for step navigation, ternary dark mode, timeout, toggle, unmount, and window size