geraete/lib/socketClient.ts
2025-11-17 15:26:43 +01:00

17 lines
342 B
TypeScript

// 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;
}