From 984513321cd75b4bee2018d07d26699a6731b528 Mon Sep 17 00:00:00 2001 From: Rama Priyanto Date: Mon, 16 Jun 2025 11:19:51 +0700 Subject: [PATCH] feat:tawkto --- app/layout.tsx | 2 ++ components/ui/tawkto/load-tawk.tsx | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 components/ui/tawkto/load-tawk.tsx diff --git a/app/layout.tsx b/app/layout.tsx index 9777007..ef41878 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -9,6 +9,7 @@ import { Metadata } from "next"; import { Providers } from "./providers"; import LoadScript from "@/utils/global"; import { type ReactNode } from "react"; +import LoadTawk from "@/components/ui/tawkto/load-tawk"; const inter = Inter({ subsets: ["latin"] }); export const metadata: Metadata = { @@ -56,6 +57,7 @@ export default function RootLayout({ children }: { children: ReactNode }) {
{children}
+ ); diff --git a/components/ui/tawkto/load-tawk.tsx b/components/ui/tawkto/load-tawk.tsx new file mode 100644 index 0000000..6e6e58a --- /dev/null +++ b/components/ui/tawkto/load-tawk.tsx @@ -0,0 +1,22 @@ +"use client"; +import { useEffect } from "react"; + +const LoadTawk = () => { + useEffect(() => { + const script = document.createElement("script"); + script.src = "https://embed.tawk.to/5d43069be5ae967ef80df561/default"; // GANTI + script.async = true; + script.charset = "UTF-8"; + script.setAttribute("crossorigin", "*"); + + document.body.appendChild(script); + + return () => { + document.body.removeChild(script); + }; + }, []); + + return null; +}; + +export default LoadTawk;