Files
kandev/apps/web/components/ws-connector.tsx
T
Carlos Florêncio 150c3f06c6 feat: session mobile design (#163)
fix: backend url
2026-02-03 03:38:15 +00:00

23 lines
594 B
TypeScript

'use client';
import { useMemo } from 'react';
import { useAppStoreApi } from '@/components/state-provider';
import { getBackendConfig } from '@/lib/config';
import { httpToWebSocketUrl } from '@/lib/ws/utils';
import { useWebSocket } from '@/lib/ws/use-websocket';
export function WebSocketConnector() {
const store = useAppStoreApi();
// Get WebSocket URL from current hostname (supports remote access)
const wsUrl = useMemo(() => {
const { apiBaseUrl } = getBackendConfig();
return httpToWebSocketUrl(apiBaseUrl);
}, []);
useWebSocket(store, wsUrl);
return null;
}