1
- import { useEffect , useMemo } from "react" ;
1
+ import { useMemo } from "react" ;
2
2
3
3
import { setBaseUrl as setASBaseUrl } from "@squonk/account-server-client" ;
4
4
import { setBaseUrl as setDMBaseUrl } from "@squonk/data-manager-client" ;
5
5
6
6
import { UserProvider } from "@auth0/nextjs-auth0/client" ;
7
- import { type EmotionCache } from "@emotion/cache" ;
8
- import { CacheProvider } from "@emotion/react" ;
7
+ import {
8
+ AppCacheProvider ,
9
+ type EmotionCacheProviderProps ,
10
+ } from "@mui/material-nextjs/v15-pagesRouter" ;
9
11
import { HydrationBoundary , QueryClient , QueryClientProvider } from "@tanstack/react-query" ;
10
12
import { ReactQueryDevtools } from "@tanstack/react-query-devtools" ;
11
13
import { enableMapSet } from "immer" ;
12
14
import { type AppProps } from "next/app" ;
13
- import Head from "next/head" ;
14
15
import { SnackbarProvider } from "notistack" ;
15
16
16
17
import { ThemeProviders } from "../components/app/ThemeProviders" ;
17
18
import { TopLevelHooks } from "../components/app/TopLevelHooks" ;
18
19
import { AS_API_URL , DM_API_URL } from "../constants/proxies" ;
19
20
import { MDXComponentProvider } from "../context/MDXComponentProvider" ;
20
- import createEmotionCache from "../utils/next/createEmotionCache" ;
21
21
22
22
import "../styles/globalStyles.scss" ;
23
23
24
- const clientSideEmotionCache = createEmotionCache ( ) ;
25
-
26
24
setDMBaseUrl ( DM_API_URL ) ;
27
25
setASBaseUrl ( AS_API_URL ) ;
28
26
@@ -31,35 +29,22 @@ enableMapSet();
31
29
// Adjust template for MUI given at
32
30
// https://github.com/mui/material-ui/blob/master/examples/nextjs-with-typescript/pages/_app.tsx
33
31
34
- type CustomAppProps = AppProps & {
35
- emotionCache ?: EmotionCache ;
36
- pageProps : { dehydratedState ?: unknown } ;
37
- } ;
32
+ type CustomAppProps = AppProps &
33
+ EmotionCacheProviderProps & {
34
+ pageProps : { dehydratedState ?: unknown } ;
35
+ } ;
38
36
39
- const App = ( { Component, pageProps, emotionCache = clientSideEmotionCache } : CustomAppProps ) => {
37
+ const App = ( { Component, pageProps } : CustomAppProps ) => {
40
38
// React-Query
41
39
const queryClient = useMemo ( ( ) => new QueryClient ( ) , [ ] ) ;
42
40
43
- // Material UI for SSR
44
- useEffect ( ( ) => {
45
- // Remove the server-side injected CSS.
46
- const jssStyles = document . querySelector ( "#jss-server-side" ) ;
47
- if ( jssStyles ) {
48
- // eslint-disable-next-line unicorn/prefer-dom-node-remove
49
- jssStyles . parentElement ?. removeChild ( jssStyles ) ;
50
- }
51
- } , [ ] ) ;
52
-
53
41
// Vercel specific code is only imported if needed
54
42
// if (process.env.NEXT_PUBLIC_VERCEL_URL) {
55
43
// import("../utils/next/vercelRedirect").then(({ vercelRedirect }) => vercelRedirect());
56
44
// }
57
45
58
46
return (
59
- < CacheProvider value = { emotionCache } >
60
- < Head >
61
- < meta content = "minimum-scale=1, initial-scale=1, width=device-width" name = "viewport" />
62
- </ Head >
47
+ < AppCacheProvider { ...pageProps } >
63
48
< ThemeProviders >
64
49
< UserProvider
65
50
loginUrl = { `${ process . env . NEXT_PUBLIC_BASE_PATH ?? "" } /api/auth/login` }
@@ -79,7 +64,7 @@ const App = ({ Component, pageProps, emotionCache = clientSideEmotionCache }: Cu
79
64
</ QueryClientProvider >
80
65
</ UserProvider >
81
66
</ ThemeProviders >
82
- </ CacheProvider >
67
+ </ AppCacheProvider >
83
68
) ;
84
69
} ;
85
70
0 commit comments