@talixo-ds/cookie-consent
v1.0.1
Published
```bash npm install @talixo-ds/cookie-consent ```
Downloads
553
Readme
@talixo-ds/cookie-consent
Installation
npm install @talixo-ds/cookie-consentImporting
import {
CookieConsent,
CookiesProvider,
Cookies
} from "@talixo-ds/cookie-consent";CookieConsent must be rendered inside CookiesProvider. The package re-exports CookiesProvider and Cookies from react-cookie so you can wrap your app without adding react-cookie as a direct dependency.
Usage
Client-only
Mount CookiesProvider at your app root (or above any CookieConsent), with no props:
<CookiesProvider>
<App />
</CookiesProvider>Inside that tree:
<CookieConsent />Server-side rendering (SSR)
Use the same CookiesProvider in the same place, but on the server pass the request cookies via the cookies prop so the initial render has access to them:
<CookiesProvider cookies={new Cookies(cookieHeader)}>
<App />
</CookiesProvider>cookieHeader is the request’s cookie string (e.g. req.headers.cookie in Node, or your framework’s equivalent). The re-exported Cookies is from react-cookie (universal-cookie). For Express you can use universal-cookie-express and pass req.universalCookies if you prefer.
