Next.js
Last updated
Was this helpful?
Last updated
Was this helpful?
This library was originally designed to work with Next.js, so integrating it is beautifully simple.
react-color-mode
provides a <script>
tag that needs to be injected as high as possible into your document (preferably in the <head>
). This script allows us to setup the color mode before the rest of the page is loaded, preventing the page from flickering on page load. It needs to be installed in your (Learn more about custom documents at ):
provides a React.Context
from which you can access and update the current color mode. The easiest wayto use this provider in a Next.js app is by installing it in your (Learn more about custom apps at ):
Once you've installed the <ColorModeContextProvider>
, accessing and updating the color mode becomes simple using the hook: