Skip to content

Instantly share code, notes, and snippets.

@officialrajdeepsingh
Last active June 24, 2022 07:33
Show Gist options
  • Save officialrajdeepsingh/8519c1e2b69a3293319913ef94f5ae5b to your computer and use it in GitHub Desktop.
Save officialrajdeepsingh/8519c1e2b69a3293319913ef94f5ae5b to your computer and use it in GitHub Desktop.
create configuration for nextjs material UI for javascript
import * as React from 'react';
import Head from 'next/head';
import { ThemeProvider } from '@mui/material/styles';
import CssBaseline from '@mui/material/CssBaseline';
import { CacheProvider } from '@emotion/react';
import theme from '../config/theme';
import createEmotionCache from '../config/createEmotionCache';
// Client-side cache, shared for the whole session of the user in the browser.
const clientSideEmotionCache = createEmotionCache();
export default function MyApp(props) {
const { Component, emotionCache = clientSideEmotionCache, pageProps } = props;
return (
<CacheProvider value={emotionCache}>
<Head>
<meta name="viewport" content="initial-scale=1, width=device-width" />
</Head>
<ThemeProvider theme={theme}>
{/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */}
<CssBaseline />
<Component {...pageProps} />
</ThemeProvider>
</CacheProvider>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment