Skip to content

fix: re-enable SSR #610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 34 additions & 40 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { GrazProvider } from "graz";
import { AppProps } from "next/app";
import Script from "next/script";
import "nextra-theme-docs/style.css";
import { ReactNode, useEffect, useState, useRef } from "react";
import { ReactNode, useEffect, useRef } from "react";
import { WagmiConfig, createConfig } from "wagmi";
import { arbitrum, avalanche, mainnet, sepolia } from "wagmi/chains";
import * as amplitude from "@amplitude/analytics-browser";
Expand Down Expand Up @@ -37,10 +37,8 @@ const config = createConfig(
);

export default function Nextra({ Component, pageProps }: NextraAppProps) {
const [mounted, setMounted] = useState(false);
const amplitudeInitialized = useRef(false);

useEffect(() => setMounted(true), []);
useEffect(() => {
TagManager.initialize(tagManagerArgs);
}, []);
Expand All @@ -54,44 +52,40 @@ export default function Nextra({ Component, pageProps }: NextraAppProps) {
}
}, []);

// Make the global context available to every page.
return (
// prevent react hydration error
mounted && (
<>
<Script
async
src="https://www.googletagmanager.com/gtag/js?id=G-7TVVW3MEK7"
/>
<Script id="google-tag">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
<>
<Script
async
src="https://www.googletagmanager.com/gtag/js?id=G-7TVVW3MEK7"
/>
<Script id="google-tag">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'G-7TVVW3MEK7');
`}
</Script>
<AskCookbook />
<GrazProvider grazOptions={{ chains: CosmosChains }}>
<WagmiConfig config={config}>
<ConnectKitProvider
theme="midnight"
customTheme={{
"--ck-connectbutton-background": "#E6DAFE",
"--ck-connectbutton-hover-background": "#F2ECFF",
"--ck-connectbutton-color": "#141227",
"--ck-font-family": "Red Hat Text, sans-serif",
"--ck-connectbutton-font-size": "14px",
}}
>
<GlobalContextProvider>
<Component {...pageProps} />
</GlobalContextProvider>
</ConnectKitProvider>
</WagmiConfig>
</GrazProvider>
</>
)
gtag('config', 'G-7TVVW3MEK7');
`}
</Script>
<AskCookbook />
<GrazProvider grazOptions={{ chains: CosmosChains }}>
<WagmiConfig config={config}>
<ConnectKitProvider
theme="midnight"
customTheme={{
"--ck-connectbutton-background": "#E6DAFE",
"--ck-connectbutton-hover-background": "#F2ECFF",
"--ck-connectbutton-color": "#141227",
"--ck-font-family": "Red Hat Text, sans-serif",
"--ck-connectbutton-font-size": "14px",
}}
>
<GlobalContextProvider>
<Component {...pageProps} />
</GlobalContextProvider>
</ConnectKitProvider>
</WagmiConfig>
</GrazProvider>
</>
);
}