import { ColorModeScript } from '@chakra-ui/color-mode' ; import Document , { DocumentContext , Head , Html , Main , NextScript , } from 'next/document' ; import { theme } from '../theme' ; class MyDocument extends Document { static async getInitialProps ( ctx ) { const initialProps = await Document . getInitialProps ( ctx ) ; return { ... initialProps } ; } render ( ) { return ( < Html > < Head /> < body > < ColorModeScript initialColorMode = { theme . config . initialColorMode } / > < Main /> < NextScript / > < /body> < /Html>); } } export default MyDocument ;