diff --git a/apps/web/lib/app-providers.tsx b/apps/web/lib/app-providers.tsx index 47280b98b9..c8381599f1 100644 --- a/apps/web/lib/app-providers.tsx +++ b/apps/web/lib/app-providers.tsx @@ -6,6 +6,7 @@ import React, { ComponentProps, ReactNode } from "react"; import DynamicIntercomProvider from "@ee/lib/intercom/providerDynamic"; +import usePublicPage from "@lib/hooks/usePublicPage"; import { createTelemetryClient, TelemetryProvider } from "@lib/telemetry"; import { trpc } from "./trpc"; @@ -40,14 +41,22 @@ const CustomI18nextProvider = (props: AppPropsWithChildren) => { const AppProviders = (props: AppPropsWithChildren) => { const session = trpc.useQuery(["viewer.session"]).data; + // No need to have intercom on public pages - Good for Page Performance + const isPublicPage = usePublicPage(); + const RemainingProviders = ( + + {props.children} + + ); + return ( - - - {props.children} - - + {isPublicPage ? ( + RemainingProviders + ) : ( + {RemainingProviders} + )} ); diff --git a/apps/web/lib/hooks/usePublicPage.ts b/apps/web/lib/hooks/usePublicPage.ts new file mode 100644 index 0000000000..90c88c90c1 --- /dev/null +++ b/apps/web/lib/hooks/usePublicPage.ts @@ -0,0 +1,9 @@ +import { useRouter } from "next/router"; + +export default function usePublicPage() { + const router = useRouter(); + const isPublicPage = ["/[user]", "/success", "/cancel", "/reschedule"].find((route) => + router.pathname.startsWith(route) + ); + return isPublicPage; +}