"use client"; import { useEffect, useState } from "react"; export interface AnalyticsData { totalViews: number; todayViews: number; uniqueVisitors: number; devices: { Desktop: number; Mobile: number; }; } export default function AnalyticsWidget() { const [stats, setStats] = useState(null); useEffect(() => { fetch("https://andre-kempf.com/backend/analytics.php?track=true") .then((res) => res.json()) .then((data) => { if (!data.error) setStats(data); }) .catch(() => null); }, []); if (!stats) { return (
$ loading_stats...
); } return (
$ sys.metrics [ today: {stats.todayViews} | total: {stats.totalViews} ]
); }