Client class is your main entry point for Uplink automation. It manages the WebSocket connection to the Uplink relay server and provides methods for worker and browser management.
Key concepts:
- Device: A physical iOS or Android device
- Worker: A worker created using the native Uplink SDK (a device can create multiple workers)
- Address: A hex-encoded identifier for workers
Connection
uplink.session()
Creates an Uplink session using your project credentials.
apiKey: Your project API key from Uplink Consoleoptions: Session configurationprojectId: Your project ID from Uplink Consoleinclude: Cryptographic key optionsecdsa: Boolean, include ECDSA keys (default: false)ecdh: Boolean, include ECDH keys (default: false)
Promise<Session> - Session object to be used with fromSession()
uplink.client.fromSession()
Creates a client from an Uplink session.
session: Session object created withuplink.session()options(optional): Connection optionsagent: Optional AI agent for natural language automation (requires@uplink-code/ai)
Promise<Client> - Connected client instance
Complete example:
uplink.client.connect() (Alternative)
Connects directly to an Uplink session via WebSocket URL. This is an alternative to using uplink.session() + fromSession().
url: WebSocket URL in the formatwss://relay.uplink.build/session/<jwt>options(optional): Connection optionsagent: Optional AI agent for natural language automation (requires@uplink-code/ai)
Promise<Client> - Connected client instance
Example:
Recommended approach: Use
uplink.session() + fromSession() for better credential management and project organization. Use connect() when you need to work with pre-generated session URLs.Browser operations
client.launch()
Launches a new browser on a worker. If no worker address is provided, uses the first available worker.
address(optional): Worker address to launch browser on
Promise<Browser> - New browser instance
Example:
client.connect()
Connects to an existing browser by its handle.
handle: Browser handle identifieraddress(optional): Worker address where browser is running
Promise<Browser> - Connected browser instance
Example:
client.browsers()
Lists all browsers on a worker.
address(optional): Worker address to query. If not provided, queries first available worker.
Promise<Browser[]> - Array of browser instances
Example:
Worker operations
client.workers()
Returns list of currently connected workers.
ClientWorker[] - Array of connected workers
Example:
client.terminate()
Terminates a worker connection.
address(optional): Worker address to terminate. If not provided, terminates first available worker.
Promise<void>
Example:
Connection management
client.close()
Closes the client connection and cleans up resources.
Promise<void>
Example:
Events
The client emits events for worker connection lifecycle.worker-connected
Emitted when a new worker connects to the session (i.e., when a device running the Uplink SDK joins).
worker-disconnected
Emitted when a worker disconnects from the session (i.e., when a device leaves or loses connection).
Types
ClientOptions
Address
Worker identifier - a hex-encoded address:Complete example
Related
ClientWorker
Device-specific operations
Browser
Browser management
Core concepts
Architecture overview
Sessions
Session management