Socket
Socket
Sign inDemoInstall

@eisberg-labs/mui-next-cookie-consent

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eisberg-labs/mui-next-cookie-consent

React Material Ui cookie consent dialog, lightweight, compatible with nextjs cookies and tailwind css.


Version published
Maintainers
1
Weekly downloads
1

Weekly downloads

Readme

Source

Downloads

React Material Ui cookie consent dialog, compatible with Nextjs cookies.

Installation

Prerequisites are:

  • @mui/base
  • tailwindcss configured
npm i --save @eisberg-labs/mui-next-cookie-consent

Usage

Just import the template with defaults:

<CookieConsent>This website uses cookies to enhance the user experience.</CookieConsent>

I use it in a nextjs app like this:


const CookieConsent = dynamic(() => import('@eisberg-labs/mui-next-cookie-consent'), {suspense: true});

export default function Layout({children}) {
  return (
    <>
      <AppHeader/>
      <div className={styles.wrapper}>{children}</div>
      <Suspense><CookieConsent
        cookieOptions={{
          expires: moment().add(1, 'years').toDate()
        }}
        confirmText="I agree"
      >This website uses cookies to enhance the user experience.</CookieConsent></Suspense>
      <Footer/>
    </>
  );
}

You can change the default styling, cookie key, set expires, register callback on Accept.

Api

NameTypeDefaultDescription
defaultNamestring'CookieConsent'Cookie key name for cookie consent
confirmTextReact.ReactNode'I understand'Confirm button text
snackbarClassNamestring'fixed p-3 z-50 bottom-0'snackbar class name
rootClassNamestring'rounded-lg bg-white shadow-2xl p-3'
buttonClassNamestring'bg-white hover:bg-gray-100 text-gray-800 font-semibold py-2 px-4 border border-gray-400 rounded shadow'
cookieOptionsCookieSerializeOptionse.g. {expires: moment().add(1, 'days').toDate()}
onAccept()=>voidOptional function that triggers after cookie consent accepted.

License

MIT © Eisberg Labs

Keywords

FAQs

Last updated on 25 Jan 2023

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