Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

SSR safety check

Blue Mouse008979b67955
diff --git a/web/app/pages/Dashboard/ProjectCard.tsx b/web/app/pages/Dashboard/ProjectCard.tsx
index c9d7f246d..2056b0d65 100644
--- a/web/app/pages/Dashboard/ProjectCard.tsx
+++ b/web/app/pages/Dashboard/ProjectCard.tsx
@@ -13,23 +13,6 @@ import { Link } from 'react-router'
import { toast } from 'sonner'
import { acceptProjectShare, pinProject, unpinProject } from '~/api'
-
-// Detect if device supports hover (i.e., not a touch-only device)
-const useIsTouchDevice = () => {
- const [isTouchDevice, setIsTouchDevice] = useState(false)
-
- useEffect(() => {
- // Check if device is touch-only (no hover support)
- const mediaQuery = window.matchMedia('(hover: none)')
- setIsTouchDevice(mediaQuery.matches)
-
- const handler = (e: MediaQueryListEvent) => setIsTouchDevice(e.matches)
- mediaQuery.addEventListener('change', handler)
- return () => mediaQuery.removeEventListener('change', handler)
- }, [])
-
- return isTouchDevice
-}
import useFeatureFlag from '~/hooks/useFeatureFlag'
import { OverallObject, Project } from '~/lib/models/Project'
import { FeatureFlag } from '~/lib/models/User'
@@ -44,6 +27,23 @@ import routes from '~/utils/routes'
import Sparkline from './Sparkline'
import { DASHBOARD_TABS } from './Tabs'
+// Detect if device supports hover (i.e., not a touch-only device)
+const useIsTouchDevice = () => {
+ const [isTouchDevice, setIsTouchDevice] = useState(() => {
+ if (typeof window === 'undefined') return false
+ return window.matchMedia('(hover: none)').matches
+ })
+
+ useEffect(() => {
+ const mediaQuery = window.matchMedia('(hover: none)')
+ const handler = (e: MediaQueryListEvent) => setIsTouchDevice(e.matches)
+ mediaQuery.addEventListener('change', handler)
+ return () => mediaQuery.removeEventListener('change', handler)
+ }, [])
+
+ return isTouchDevice
+}
+
interface ProjectCardProps {
live?: string | number | null
overallStats?: OverallObject