Enable dark mode for Next.js apps
next-dark-mode is a theme for Next.js apps that allows users to switch between a dark and light mode. It also includes an auto mode feature that automatically adjusts the theme based on the user’s operating system preferences. The theme uses configurable cookies to persist the theme state, preventing any page load glitches.
To install next-dark-mode, follow these steps:
npm install next-dark-mode
To use next-dark-mode in your Next.js app, follow these steps:
/pages
with the HOC withDarkMode.If you are using CSS-in-JS libraries like emotion or styled-components, follow these additional steps:
/pages
with the HOC withDarkMode.next-dark-mode is a theme for Next.js apps that provides support for dark and light modes, as well as an auto mode that adjusts the theme based on the user’s operating system preferences. It uses configurable cookies to persist the theme state and avoids any page load glitches. To use next-dark-mode, ensure that you have react@16.8.0 or higher installed and wrap your app component with the provided HOC.