diff --git a/src/client.ts b/src/client.ts index dca3448..cb0d2e2 100644 --- a/src/client.ts +++ b/src/client.ts @@ -19,10 +19,16 @@ type UpdateListener = { }; export function SocketDBClient({ - url = `ws://${window.location.hostname}:${window.location.port}`, + url, store = createStore(), socketClient = createWebsocketClient({ url }), }: { url?: string; store?: Store; socketClient?: SocketClient } = {}) { + if (!url) + url = + typeof window !== 'undefined' + ? `ws://${window.location.hostname}:${window.location.port}` + : 'ws://localhost:8080'; + const subscribedPaths: string[] = []; const updateListener: UpdateListener = {};