Skip to content

Instantly share code, notes, and snippets.

@DanielHemmati
Created November 1, 2022 15:26
Show Gist options
  • Save DanielHemmati/14db96ba3fce0ffaec4d2c3a0bd339d4 to your computer and use it in GitHub Desktop.
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.
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