Skip to main content

Configuration

Basic options

OptionTypeDefaultDescription
enabledbooleantrueDisable the plugin without removing it from the config.
titlestring'Cookie consent'Heading shown in the modal or toast.
descriptionstring'We use cookies…'Body text. Supports [label](url) markdown links.
linksArray<{label,href}>[]Links to privacy, cookie, or terms pages.
acceptAllTextstring'Accept all'Label for the button that grants every category.
rejectTextstring'Reject optional'Label for the button that keeps only necessary cookies enabled.
storageKeystring'cookie-consent-preferences'localStorage key.
consentExpiryDaysnumberunsetRe-prompt after this many days. Must be positive.
toastModebooleanfalseShow a bottom toast instead of a centered modal.
showDetailsButtonbooleantrueShow the control that expands the category descriptions.
categoriesobjectbuilt-in labelsRelabel, describe, or hide individual cookie categories.
googleConsentModeobjectunsetConfigure optional Google Consent Mode v2 support.
rejectOptionalTextstringunsetDeprecated fallback for rejectText.
rejectAllTextstringunsetDeprecated fallback for rejectText. It does not reject necessary cookies.

Complete example

{
title: 'We Value Your Privacy',
description:
'We use cookies to improve your experience, analyze site traffic, and personalize content. By clicking "Accept All", you consent to our use of cookies. You can also [manage your preferences](/cookie-preferences) or read our [Privacy Policy](/privacy).',
links: [
{ label: 'Privacy Policy', href: '/privacy' },
{ label: 'Cookie Policy', href: '/cookies' },
{ label: 'Terms of Service', href: '/terms' },
],
acceptAllText: 'Accept all cookies',
rejectText: 'Essential only',
toastMode: true,
storageKey: 'my-site-cookie-consent',
consentExpiryDays: 180,
showDetailsButton: true,
}

rejectOptionalText and rejectAllText remain available for backward compatibility. New configurations should use rejectText. All three names trigger the same behavior: necessary cookies remain enabled, and analytics, marketing, and functional cookies are rejected.

For category-level controls, see Categories. For GTM/GA4 integration, see Google Consent Mode.

TypeScript types

import type {
CookieConsentOptions,
CookieCategory,
CookieConsentLink,
CookiePreferences,
ConsentState,
GoogleConsentModeConfig,
} from 'docusaurus-plugin-cookie-consent';