react 0.4.0
This release published @cookieyes/react@0.4.0, @cookieyes/nextjs@0.4.0, @cookieyes/core@0.3.0 and @cookieyes/cli@0.3.0.
Install
Minor changes
Add a GitHub star nudge to init. Every npx @cookieyes/cli init run now prints a short, non-intrusive note before the final summary inviting developers to star the repo at https://github.com/cookieyes/cookieyes.
In @cookieyes/cli.
Add a consent event API for reacting to consent changes.
- Core:
consentStore.on("save" | "change", listener, { category? })returning an unsubscribe function. - React / Next.js: the
useOnConsentChange(type, listener, options?)hook (cleans up on unmount, no-op during SSR).
change fires only when a category actually differs; save fires on every save. Listeners fire once immediately with the current state (isInitial: true), and one throwing listener never blocks the others. Existing subscribe/subscribeToConsentChanges/onConsentUpdate continue to work unchanged.
In @cookieyes/core, @cookieyes/nextjs, @cookieyes/react.
Translations for custom UIs, with live language switching.
useTranslations()now re-renders when the language changes (previously fixed at setup).- New
useLanguage()hook: read the active language, its reading direction (ltr/rtl), the loaded languages, and switch language live withsetLanguage(tag); no page reload. - Framework-less:
consentStorenow carriestranslations,getLanguageInfo(),setLanguage(),getCategoryText(), andcategories(the resolved taxonomy in effect), andsubscribefires on a language switch, so a vanilla custom UI can switch language and follow whatever taxonomy is configured. - Languages in
i18n.messagescan be partial; any missing text falls back to English. - Custom categories are translatable through the same
i18n.messages, keyed by category id; a translation overrides the category's config label per language. - New
i18n.loadLanguage(tag)to load a language on demand (import it or fetch from your own URL) instead of bundling every language upfront. - Core helpers
mergeTranslations,getTextDirection,pickLanguageare exported for non-React use.
The starting language is resolved per page load (explicit locale → browser → English); the visitor's choice isn't persisted by the SDK.
In @cookieyes/core, @cookieyes/nextjs, @cookieyes/react.
Make the components easy to restyle.
- Every component labels its pieces with
data-cy-part(and toggles withdata-cy-state="on" | "off") for precise CSS targeting. The names are also exported as the typedCY_PART/CY_STATEconstants. - The styled presets (
CookieBanner,CookiePreferences,CookieOptOut) now acceptclassName/style, merged onto their visible card on top of the defaults. - Control primitives accept
asChild: render your own element and the SDK wires its behaviour (click action,data-cy-part, ref) onto it, composing with your own handlers/classes.
Purely additive: existing setups render identically.
In @cookieyes/nextjs, @cookieyes/react.
Source
Read the full diff and commit history for react 0.4.0 on GitHub.