import { GetServerSidePropsContext } from 'next'; import { useState } from 'react'; import { AppProps } from 'next/app'; import { getCookie, setCookies } from 'cookies-next'; import Head from 'next/head'; import { MantineProvider, ColorScheme, ColorSchemeProvider } from '@mantine/core'; import { NotificationsProvider } from '@mantine/notifications'; export default function App(props: AppProps & { colorScheme: ColorScheme }) { const { Component, pageProps } = props; const [colorScheme, setColorScheme] = useState(props.colorScheme); const toggleColorScheme = (value?: ColorScheme) => { const nextColorScheme = value || (colorScheme === 'dark' ? 'light' : 'dark'); setColorScheme(nextColorScheme); setCookies('mantine-color-scheme', nextColorScheme, { maxAge: 60 * 60 * 24 * 30 }); }; return ( <> Mantine next example ); } App.getInitialProps = ({ ctx }: { ctx: GetServerSidePropsContext }) => ({ colorScheme: getCookie('mantine-color-scheme', ctx) || 'light', });