Created
November 1, 2022 15:26
-
-
Save DanielHemmati/14db96ba3fce0ffaec4d2c3a0bd339d4 to your computer and use it in GitHub Desktop.
next.js with next-auth and react query. the way type is written is really messy.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { SessionProvider } from "next-auth/react"; | |
import "../styles/globals.css"; | |
import { | |
Hydrate, | |
QueryClient, | |
QueryClientProvider, | |
} from "@tanstack/react-query"; | |
import { ReactQueryDevtools } from "@tanstack/react-query-devtools"; | |
import type { AppProps } from "next/app"; | |
import type { Session } from "next-auth"; | |
import { useState } from "react"; | |
function MyApp({ | |
Component, | |
pageProps: { session, ...pageProps }, | |
}: AppProps<{ session: Session; dehydratedState: unknown }>) { | |
const [queryClient] = useState(() => new QueryClient()); | |
return ( | |
<QueryClientProvider client={queryClient}> | |
<SessionProvider session={session}> | |
<Hydrate state={pageProps.dehydratedState}> | |
<Component {...pageProps} /> | |
</Hydrate> | |
</SessionProvider> | |
</QueryClientProvider> | |
); | |
} | |
export default MyApp; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment