From 8c4df0ff57c1dad922745bfb3365952e1698bb59 Mon Sep 17 00:00:00 2001
From: MohamedBassem <me@mbassem.com>
Date: Sat, 19 Apr 2025 01:45:47 +0100
Subject: fix: Fix server side error on clipboard check

---
 .../web/components/dashboard/bookmarks/BookmarkOptions.tsx | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

(limited to 'apps/web/components/dashboard/bookmarks/BookmarkOptions.tsx')

diff --git a/apps/web/components/dashboard/bookmarks/BookmarkOptions.tsx b/apps/web/components/dashboard/bookmarks/BookmarkOptions.tsx
index 06bead4f..4725c77f 100644
--- a/apps/web/components/dashboard/bookmarks/BookmarkOptions.tsx
+++ b/apps/web/components/dashboard/bookmarks/BookmarkOptions.tsx
@@ -1,6 +1,6 @@
 "use client";
 
-import { useState } from "react";
+import { useEffect, useState } from "react";
 import { Button } from "@/components/ui/button";
 import {
   DropdownMenu,
@@ -48,7 +48,17 @@ export default function BookmarkOptions({ bookmark }: { bookmark: ZBookmark }) {
   const linkId = bookmark.id;
 
   const demoMode = !!useClientConfig().demoMode;
-  const isClipboardAvailable = navigator && !!navigator.clipboard;
+
+  const [isClipboardAvailable, setIsClipboardAvailable] = useState(false);
+
+  useEffect(() => {
+    // This code only runs in the browser
+    setIsClipboardAvailable(
+      typeof window !== "undefined" &&
+        window.navigator &&
+        !!window.navigator.clipboard,
+    );
+  }, []);
 
   const { setOpen: setManageListsModalOpen, content: manageListsModal } =
     useManageListsModal(bookmark.id);
-- 
cgit v1.2.3-70-g09d2

