Cookie Banner
This plugin adds a cookie banner to your Next.js Supabase application. It's a simple component that will store the user's consent in a cookie. This banner will stop appearing once the user has given their consent - or rejected it.
This plugin adds a cookie banner to your Next.js application. It's a simple component that will store the user's consent in a cookie. This banner will stop appearing once the user has given their consent - or rejected it.
Using the Plugin
Installation
To install the plugin, you can use git subtrees from your original repository:
After running this command, you will have the plugin in your repository at plugins/cookie-banner
. Once pulled, you can apply any customization you need.
Using the CLI
If you're using the CLI, you can run the following command to install the plugin:
Follow the instructions to install the plugin.
If the installation fails
Some users are not able to install using the GitHub SSH URL. If you're having issues with that:
- properly set up SSH access to GitHub with your SSH key
- use the HTTPS URL instead of the SSH URL
To use the HTTPS URL, you can run the following command:
Translations
Add the translations to your public/locales/en/common.json
file:
Importing the Plugin
You can import the CookieBanner
component from the plugin in your _app. tsx
file and add it to your application:
API
To retrieve the current consent status, you can use the useCookieConsent
:
You can use this hook to decide whether to load third-party scripts or not. For example, you can use it to load Google Analytics only if the user has consented:
Keeping the plugin up to date
To keep the plugin up to date, you can use git subtrees again: