Developer
WebSocket API
Overview

WebSocket API

XSOverlay runs a WebSocket server that apps can use to send notifications, read device and overlay state, change settings, and drive the overlay.

Send your first notification

With XSOverlay running, this shows a notification in VR:

hello.js
const ws = new WebSocket('ws://localhost:42070/?client=MyApp');
 
ws.addEventListener('open', () => {
  ws.send(JSON.stringify({
    target: 'xsoverlay',
    command: 'SendNotification',
    jsonData: JSON.stringify({ title: 'Hello from MyApp', timeout: 5 }),
  }));
});

To go further, set up the client helpers used by every example in Commands.