Socket
Socket
Sign inDemoInstall

@eo/next-ccm

Package Overview
Dependencies
132
Maintainers
13
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @eo/next-ccm

Cookie Consent Module for EO Next.js websites


Version published
Maintainers
13
Created

Readme

Source

@eo/next-ccm

Easy use of the NPO Cookie Consent Module within React projects.

Originally a clone of @bnnvara/ccm version 1.1.0. We removed all non-react npm dependencies, changed the module to TypeScript, added a README, and added Tailwind.

Usage

Installation and configuration

Execute the following:

pnpm install @eo/next-ccm

Add @eo/next-ccm to your project's tailwind content configuration, like so:

import type { Config } from 'tailwindcss'

const config: Config = {
  content: [
    ...
    './node_modules/@eo/next-ccm/dist/**/*.{js,ts,jsx,tsx}',
  ],
  theme: {
    colors: ...,
    fontFamily: ...,
  },
  plugins: ...,
}
export default config

Initialization

Implement the CookieConsentModule in your root layout.

import { CookieConsentModule } from '@eo/next-ccm';

export default const () => (
    // Using cookies.eo.nl instead of (the default) ccm.npo.nl,
    // because we want to use 1st party cookies instead of 3rd party
    <CookieConsentModule 
        organisation="EO" 
        site="eo.nl"
        ccmDomain="https://cookies.eo.nl"
    />
)
import { CookieConsentPlaceholder, api } from '@eo/next-ccm';

// The `ssr={true}` (default) will render the placeholder during Server Rendering.
// Consequently, `ssr={false}` will render the placeholder during Client Rendering.
export default const () => (
    <CookieConsentPlaceholder
        renderPlaceholder={<p>OOPS! No permission given!</p>} 
        permissions={[
            api.permissionTypes.SOCIAL, 
            api.permissionTypes.ANALYTICS,
        ]}
        ssr={true}
    >
        Granted content
    </CookieConsentPlaceholder>
)

To make sure a user doesn't get cookies they have not given permission for, be sure to always place your external content within the <CookieConsentPlaceholder></CookieConsentPlaceholder> tags. Always classify what permissions are required to view the wrapped content. See #permissions.

If CookieConsentPlaceholder determines not all required permissions were given, the value of renderPlaceholder is rendered instead, until the required permissions have been given. If no renderPlaceholder is given, a default placeholder is rendered. A custom renderPlaceholder is probably preferred.

Interacting with NPO CCM script and popup

If you want to interact with the NPO cookie management, you can place buttons within your placeholder (or anywhere else on your site for that matter) with specific properties to do so.

Opening the NPO cookie popup can be done by adding the ccm_message_link class to a button or anchor tag. Suppose your content cannot be showed and you want to highlight the specific cookie categories for which permission is required, you can bring up the NPO CCM popup and highlight those specific categories with class ccm_message_highlight_link and property data-ccm-categories="social,analytics".

Examples:

<!-- Triggers NPO cookie popup -->
<a href="#" className="ccm_message_link">Aanpassen</a>

<!-- Triggers NPO cookie popup, highlights the categories for which permission is needed -->
<a href="#" className="ccm_message_highlight_link" data-ccm-categories="social,analytics">Aanpassen</a>

Permissions

Cookies can be classified in multiple categories. To use a cookie within a category X, the user must have given the permission belonging to X.

CategoryPermission keyPermission value
po_cc_necessaryapi.permissionTypes.NECESSARYnecessary
po_cc_analyticsapi.permissionTypes.ANALYTICSanalytics
po_cc_socialapi.permissionTypes.SOCIALsocial
po_cc_advertisingapi.permissionTypes.ADVERTISINGadvertising
po_cc_recommendationsapi.permissionTypes.RECOMMENDATIONSrecommendations
po_cc_miscellaneousapi.permissionTypes.MISCELLANEOUSmiscellaneous

Keywords

FAQs

Last updated on 05 Feb 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc