Files
kandev/apps/web/components/ws-connector.tsx
T
2026-02-19 22:18:01 +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;
}