Skip to main content
Home

Built and signed on GitHub Actions

A very simple cookie library

This package works with Node.js, Deno, BrowsersIt is unknown whether this package works with Cloudflare Workers, Bun
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
This package works with Browsers
JSR Score
100%
Published
7 months ago (0.3.0)

HT Cookie

Build Publish

A very simple cookie and local storage library with no dependencies.

JSR

NPM

Add to project

Using pnpm:

pnpm add jsr:@harmless/ht-cookie

pnpm add ht-cookie

Using deno:

deno add jsr:@harmless/ht-cookie

deno add ht-cookie

Using npm:

npx jsr add @harmless/ht-cookie

npm add ht-cookie

Using yarn:

yarn add jsr:@harmless/ht-cookie

yarn add ht-cookie

How to use

Cookies

import { Cookie } from "ht-cookie";

function syncExample() {
    Cookie.set(name: string, data: string, options?: CookieOptions): void;
    Cookie.get(name: string): string | null;
    Cookie.remove(name: string): void;
}

async function asyncExample() {
    await Cookie.aSet(name: string, data: string, options?: CookieOptions) : Promise<void>;
    await Cookie.aGet(name: string): Promise<string | null>;
    await Cookie.aRemove(name: string): Promise<void>;
}
interface CookieOptions {
    maxAge?: number,
    expires?: Date,
    domain?: string,
    path?: string,
    sameSite?: "strict" | "lax" | "none",
    secure?: boolean,
    partitioned?: boolean,
}

Local Storage

import { LocalStorage } from "ht-cookie";

function syncExample() {
    LocalStorage.set(name: string, data: string, maxAge?: number): void;
    LocalStorage.get(name: string): string | null;
    LocalStorage.remove(name: string): void;
}

async function asyncExample() {
    await LocalStorage.aSet(name: string, data: string, maxAge?: number) : Promise<void>;
    await LocalStorage.aGet(name: string): Promise<string | null>;
    await LocalStorage.aRemove(name: string): Promise<void>;
}
Built and signed on
GitHub Actions

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@harmless/ht-cookie

Import symbol

import * as ht_cookie from "@harmless/ht-cookie";
or

Import directly with a jsr specifier

import * as ht_cookie from "jsr:@harmless/ht-cookie";

Add Package

pnpm i jsr:@harmless/ht-cookie
or (using pnpm 10.8 or older)
pnpm dlx jsr add @harmless/ht-cookie

Import symbol

import * as ht_cookie from "@harmless/ht-cookie";

Add Package

yarn add jsr:@harmless/ht-cookie
or (using Yarn 4.8 or older)
yarn dlx jsr add @harmless/ht-cookie

Import symbol

import * as ht_cookie from "@harmless/ht-cookie";

Add Package

vlt install jsr:@harmless/ht-cookie

Import symbol

import * as ht_cookie from "@harmless/ht-cookie";

Add Package

npx jsr add @harmless/ht-cookie

Import symbol

import * as ht_cookie from "@harmless/ht-cookie";

Add Package

bunx jsr add @harmless/ht-cookie

Import symbol

import * as ht_cookie from "@harmless/ht-cookie";