import type { AppProps } from "next/app" ; import { ToastContainer } from "react-toastify" ; import "../styles/reset.css" ; import "react-toastify/dist/ReactToastify.min.css" ; import { useRouter } from "next/dist/client/router" ; import { useEffect } from "react" ; import * as gtag from "../lib/gtag" ; function MyApp ( { Component , pageProps } ) { const router = useRouter ( ) ; useEffect ( ( ) => { const handleRouteChange = ( url ) => { gtag . pageview ( url ) ; } ; router . events . on ( "routeChangeComplete" , handleRouteChange ) ; return ( ) => { router . events . off ( "routeChangeComplete" , handleRouteChange ) ; } ; } , [ router . events ] ) ; return ( < > < Component { ... pageProps } / > < ToastContainer /> < />); } export default MyApp ;