// lib/socketClient.ts 'use client'; import { io, Socket } from 'socket.io-client'; let socket: Socket | null = null; export function getSocket(): Socket { if (!socket) { // Standard: gleiche Origin, /socket.io socket = io({ path: '/api/socketio', // entspricht unserem Server-Endpunkt unten }); } return socket; }