Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

WebSocketFactory

import { WebSocketFactory } from "https://esm.sh/@supabase/supabase-js@2.101.0/dist/index.d.mts";

Utilities for creating WebSocket instances across runtimes.

class WebSocketFactory {
private constructor();
static private detectEnvironment;
 
static getWebSocketConstructor(): WebSocket;
static isWebSocketSupported(): boolean;
}

§Constructors

§
new WebSocketFactory() private
[src]

Static-only utility – prevent instantiation.

§Static Properties

§
detectEnvironment
[src]

§Static Methods

§
getWebSocketConstructor(): WebSocket
[src]

Returns the best available WebSocket constructor for the current runtime.

@example

Example with error handling

try {
  const WS = WebSocketFactory.getWebSocketConstructor()
  const socket = new WS('wss://example.com/socket')
} catch (error) {
  console.error('WebSocket not available in this environment.', error)
}
§
isWebSocketSupported(): boolean
[src]

Detects whether the runtime can establish WebSocket connections.

@example

Example in a Node.js script

if (!WebSocketFactory.isWebSocketSupported()) {
  console.error('WebSockets are required for this script.')
  process.exitCode = 1
}