> For the complete Lynkow documentation index in agent-friendly format, see [llms.txt](/llms.txt).

# SDK Types: Cookies & Consent

**Published**: 2026-11-30
**Category**: Types

> **Related services:** **CookiesService**: `lynkow.cookies.getConfig()`, `lynkow.cookies.logConsent()` | **ConsentService**: `lynkow.consent.acceptAll()`, `lynkow.consent.destroy()`, `lynkow.consent.getCategories()`, `lynkow.consent.getConfig()`, `lynkow.consent.hasConsented()`, `lynkow.consent.hide()`, `lynkow.consent.logConsent()`, `lynkow.consent.rejectAll()`, `lynkow.consent.reset()`, `lynkow.consent.setCategories()`, `lynkow.consent.show()`, `lynkow.consent.showPreferences()`

## `ConsentCategories`

*Interface*

The visitor's answer per cookie category: `true` allows the category's
scripts, `false` blocks them. Returned by
ConsentService.getCategories and sent with the `'consent-changed'`
client event.

| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| `analytics` | `boolean` | No | Analytics cookies and scripts. When `false` on an `'opt-in'` or `'opt-out'` site, the Lynkow tracker records nothing. |
| `marketing` | `boolean` | No | Consent to marketing and advertising cookies (ad networks,<br>retargeting). Required before loading scripts classified as<br>`marketing` in the site's cookie config. |
| `necessary` | `boolean` | No | Strictly necessary cookies. Always `true`: the visitor cannot refuse them. |
| `preferences` | `boolean` | No | Consent to personalization and preference cookies (theme, language,<br>non-essential UI state). Required before loading scripts classified<br>as `preferences` in the site's cookie config. |


---

## `ConsentMode`

*TypeAlias*

How the site asks for cookie consent: `'opt-in'` blocks optional cookies
until the visitor accepts, `'opt-out'` allows them until the visitor
refuses, `'notice-only'` informs without offering a choice.

```typescript
type ConsentMode = "opt-in" | "opt-out" | "notice-only"
```

---

## `ConsentShowOptions`

*Interface*

Options for ConsentService.show.

| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| `config` | `CookieConfig` | Yes | A CookieConfig you already fetched, for example on the server, used instead of a new request. |
| `force` | `boolean` | Yes | Show the banner even when the site set `showOnFirstVisit: false`. Pass it from a control the visitor clicked. |


---

## `CookieCategory`

*Interface*

A cookie consent category grouping related cookies and scripts.
Users accept or reject entire categories (not individual cookies).

| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| `description` | `string` | No | Description explaining what cookies in this category do.<br>Displayed in the consent banner's detailed/customize view. |
| `id` | `string` | No | Machine-readable category identifier.<br>Standard values: `'necessary'`, `'analytics'`, `'marketing'`, `'preferences'`.<br>Used as the key in CookiePreferences when recording consent. |
| `name` | `string` | No | Human-readable category name displayed in the consent banner. |
| `required` | `boolean` | No | `true` when the visitor cannot refuse this category, as for `'necessary'`. Render its toggle checked and disabled. |


---

## `CookieConfig`

*Interface*

A site's cookie consent configuration: mode, banner texts and styling,
categories and gated scripts. Returned by `cookies.getConfig()` and
`consent.getConfig()`.

| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| `borderRadius` | `number` | Yes | Corner radius of the banner and its buttons, in pixels, from 0 to 50. |
| `buttonSize` | `"compact" \| "comfortable"` | Yes | Size of the banner and preferences buttons.<br>- `'compact'` (default): smaller buttons, about 34px tall.<br>- `'comfortable'`: every button at least 44px tall, the WCAG 2.2 AAA target size. |
| `categories` | `CookieCategory[]` | No | The site's enabled categories, in display order, with texts in the requested locale. |
| `consentMode` | `ConsentMode` | Yes | Consent mode, see ConsentMode. Under `'notice-only'`, render one acknowledge button and no category toggles. |
| `cookiePolicyUrl` | `string \| null` | Yes | URL to a dedicated cookie policy page (separate from the privacy policy).<br>`null` when no cookie policy URL has been configured.<br>Some sites use a single privacy policy; others maintain a separate cookie policy. |
| `enabled` | `boolean` | No | Whether the cookie consent banner is enabled for this site.<br>When `false`, no banner should be shown and no consent logic is needed. |
| `fontSize` | `number` | Yes | Banner font size in pixels, from 11 to 17. |
| `layout` | `"floating"` | No | Banner layout style. Currently only `'floating'` is supported<br>(a dismissable card overlay, not a full-width bar). |
| `maxWidth` | `number` | Yes | Maximum banner width in pixels, from 280 to 1200 (default 580). Ignored below a 600px viewport. |
| `orientation` | `"auto" \| "column"` | Yes | `'auto'` lays the banner out in a row from 600px wide and in a column below; `'column'` always uses a column. |
| `position` | `"bottom-left" \| "bottom-right"` | No | Screen position of the floating consent banner.<br>- `'bottom-left'`: anchored to the bottom-left corner<br>- `'bottom-right'`: anchored to the bottom-right corner |
| `primaryColor` | `string` | Yes | Accent color as `#rrggbb`. The built-in banner uses themeStyles first and falls back to this. |
| `privacyPolicyUrl` | `string \| null` | Yes | URL to the site's privacy policy page.<br>`null` when no privacy policy URL has been configured.<br>Should be rendered as a clickable link in the banner. |
| `showCustomizeButton` | `boolean` | Yes | Whether to show the "Customize" button that lets users pick categories individually.<br>When `false`, only "Accept All" and "Reject All" buttons are shown. |
| `showOnFirstVisit` | `boolean` | Yes | Whether the banner shows by itself on a first visit. When `false`, open it from a control such as a footer link. |
| `texts` | `CookieTexts` | No | Localized text strings for the banner UI.<br>All strings are ready for display without further formatting. |
| `theme` | `"light" \| "dark" \| "auto"` | No | Color theme for the banner:<br>- `'light'`: white/light background with dark text<br>- `'dark'`: dark background with light text<br>- `'auto'`: follows the user's OS/browser color scheme preference<br><br>When `'auto'`, use themeStyles to get the exact colors for each scheme. |
| `themeStyles` | `{ dark: { bgColor: string; primaryColor: string; textColor: string }; light: { bgColor: string; primaryColor: string; textColor: string } }` | Yes | Banner colors for the light and dark schemes. Use the one matching theme, or the site's current scheme under `'auto'`. |
| `thirdPartyScripts` | `ThirdPartyScript[]` | Yes | Third-party scripts to inject based on the user's consent preferences.<br>Each script is tied to a category; only inject scripts whose category<br>the user has accepted. Empty array when no scripts are configured. |
| `version` | `string` | Yes | Version of the banner text in this locale: a 64-character SHA-256 hex digest of the texts and category labels. Consent logs record the same value. |


---

## `CookiePreferences`

*TypeAlias*

Map of cookie category IDs to the user's consent decision.
`true` means the user accepted that category; `false` means rejected.
Used when calling `cookies.logConsent()` to record preferences.

```typescript
type CookiePreferences = Record<string, boolean>
```

---

## `CookieTexts`

*Interface*

Banner texts in the requested locale: the site's own wording, or Lynkow's
default wording for any text the site left unchanged.

| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| `acceptAll` | `string` | No | Label for the "Accept All" button that grants consent for all categories. |
| `customize` | `string` | No | Label for the "Customize" button that opens the detailed category preferences. |
| `description` | `string` | No | Main description/message shown in the cookie banner.<br>Typically explains that the site uses cookies and links to the privacy policy. |
| `privacyPolicy` | `string` | No | Link text pointing to the privacy/cookie policy page. |
| `rejectAll` | `string` | No | Label for the "Reject All" button that only allows necessary cookies. |
| `save` | `string` | No | Label for the "Save" button in the detailed preferences view.<br>Saves the user's per-category choices. |


---

## `ThirdPartyScript`

*Interface*

A third-party script that should be injected into the page
based on the user's consent for its category.
Only inject this script's HTML when the user has accepted the corresponding
cookie category.

| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| `category` | `"necessary" \| "analytics" \| "marketing" \| "preferences" \| string & object` | No | Cookie consent category this script belongs to: the `id` of one of the<br>site's consent categories (CookieCategory), a custom one included.<br>Only inject this script when the user has accepted this category.<br>The four standard categories:<br>- `'necessary'`: always loaded (no consent required)<br>- `'analytics'`: tracking and analytics scripts<br>- `'marketing'`: advertising and remarketing scripts<br>- `'preferences'`: personalization and functional scripts |
| `id` | `string` | No | Unique identifier for this script configuration.<br>Stable across requests; can be used as a React key or for deduplication. |
| `name` | `string` | No | Human-readable name for this script.<br>For admin reference; not typically displayed to end users. |
| `script` | `string` | No | Raw HTML content to inject into the page.<br>May contain `<script>` tags, `<noscript>` blocks, or inline scripts.<br>Should be inserted into the DOM using `innerHTML` or a safe injection method.<br>The HTML is pre-sanitized by the admin dashboard. |