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

# SDK Types: Cookies & Consent

**Publié le** : 2026-08-20
**Catégorie** : Types

# SDK Types: Cookies & Consent

> **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*

User consent state for each cookie category Lynkow manages. Used as
input to ConsentService.setCategories and emitted as the payload
of the `'consent-changed'` client event.

A category set to `false` means the corresponding scripts (from the
site's cookie configuration) MUST NOT be loaded; a category set to
`true` authorises them.

| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| `analytics` | `boolean` | No | Consent to first-party and third-party analytics (e.g. the Lynkow<br>tracker, Google Analytics). When `false`, the analytics service<br>automatically becomes a no-op. |
| `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 (session, CSRF). Always `true`: users<br>cannot opt out because the site would be non-functional without them.<br>Included in the type so consent payloads remain uniform. |
| `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. |


---

## `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 | Whether this category is required and cannot be toggled off by the user.<br>Always `true` for the `'necessary'` category (essential cookies).<br>When `true`, the toggle is disabled/checked in the consent UI.<br>When `false`, the user can opt in or out of this category. |


---

## `CookieConfig`

*Interface*

Full cookie consent banner configuration.
Returned by `cookies.getConfig()`.
Contains all settings needed to render and manage a GDPR-compliant consent banner.

| Property | Type | Optional | Description |
| --- | --- | --- | --- |
| `borderRadius` | `number` | Yes | Border radius in pixels for the banner container and buttons.<br>Use `0` for sharp corners, `8`-`12` for rounded, `9999` for pill-shaped buttons. |
| `categories` | `CookieCategory[]` | No | Cookie categories that users can accept or reject.<br>Always includes at least a `'necessary'` category with `required: true`.<br>Order matches the display order in the preferences UI. |
| `consentMode` | `"opt-in" \| "opt-out"` | Yes | How consent is handled:<br>- `'opt-in'`: all non-necessary cookies are blocked until the user explicitly accepts.<br>  This is the GDPR-compliant default for EU sites.<br>- `'opt-out'`: all cookies are active by default; user can reject them.<br>  Less restrictive, suitable for non-EU sites.<br><br>Only present when enabled is `true`. |
| `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 | Font size in pixels for the banner text.<br>Constrained to the range 11-17. Values outside this range are clamped. |
| `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 on desktop. Range 280–1200, default 580.<br>Applies to both `'auto'` and `'column'` orientations. Below 600px viewport<br>width this value is ignored and the banner expands to `calc(100vw - 20px)`<br>so it never overflows the screen on mobile. |
| `orientation` | `"auto" \| "column"` | Yes | Banner layout orientation.<br>- `'auto'` (default): row layout on screens at least 600px wide,<br>  automatically stacked into a column under 600px.<br>- `'column'`: forced column layout at every screen size.<br><br>In every mode the banner is height-capped to the viewport with internal<br>scrolling, so it never overflows the screen. |
| `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 | Primary accent color for buttons and interactive elements.<br>Format: 6-digit hex with `#` prefix (e.g. `'#3b82f6'`).<br>Applied to the "Accept All" button and toggle switches. |
| `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 to automatically show the banner on the user's first visit.<br>When `false`, the banner must be triggered manually (e.g. via a footer link).<br>Only present when enabled is `true`. |
| `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 | Per-theme color overrides for light and dark modes.<br>Only relevant when theme is `'auto'`.<br>When theme is `'light'` or `'dark'`, use the corresponding sub-object. |
| `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. |


---

## `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*

Localized text strings for the cookie consent banner.
All fields are pre-configured by the site admin and ready for display.

| 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. |