init
This commit is contained in:
35
src/app/layout.tsx
Normal file
35
src/app/layout.tsx
Normal file
@@ -0,0 +1,35 @@
|
||||
"use client";
|
||||
|
||||
import { Provider } from "@/components/ui/provider";
|
||||
import { UrqlProvider, ssrExchange, cacheExchange, fetchExchange, createClient } from '@urql/next';
|
||||
import { useMemo } from "react";
|
||||
|
||||
export default function RootLayout({
|
||||
children
|
||||
}: Readonly<{
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
|
||||
const [client, ssr] = useMemo(() => {
|
||||
const ssr = ssrExchange({
|
||||
isClient: typeof window !== 'undefined',
|
||||
});
|
||||
const client = createClient({
|
||||
url: process.env.NEXT_PUBLIC_GRAPHQL_URL || "",
|
||||
exchanges: [cacheExchange, ssr, fetchExchange],
|
||||
suspense: true,
|
||||
});
|
||||
|
||||
return [client, ssr];
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<html lang="en" suppressHydrationWarning>
|
||||
<body>
|
||||
<UrqlProvider client={client} ssr={ssr}>
|
||||
<Provider>{children}</Provider>
|
||||
</UrqlProvider>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user