Skip to content
NewiPhone Duo, live in your browser. Try it →

Reference JavaScript SDK

JavaScript Device SDK Reference

Drive an iOS, Android, Apple TV, Android TV or Roku session from code: start sessions, send taps and gestures, and react to stream events with the JS SDK.

The VibeView SDK is a JavaScript/TypeScript library for driving a live iOS or Android simulator session programmatically from your own application code — starting sessions, sending taps and gestures, and reacting to stream events.

If you just want to drop a live device into a web page (your marketing site, docs, or a demo page) with no application code of your own, use Embedding instead — it only requires pasting an iframe snippet.

Overview

The SDK handles the full lifecycle of a simulator session: creating it, connecting to the video stream, forwarding user interactions, and cleaning up resources when done. It supports two usage patterns:

  • React component — A <VibeView /> wrapper for React applications (available via the @scriptx-com/vibeview-sdk/react subpath).
  • Vanilla JS client — The VibeViewClient class for any JavaScript environment.

Both approaches use the same underlying client and support the same configuration options.

Installation

The SDK is distributed as @scriptx-com/vibeview-sdk, a private package. It is not openly downloadable — access is granted to your organization, and support sends you the one-time setup for your package manager along with it.

Contact support@vibeview.io to request access.

The SDK requires Node.js 14+ and works in browsers with WebCodecs or Media Source Extensions (MSE) with H.264. See Browser Compatibility.

React Usage

Import the component from the @scriptx-com/vibeview-sdk/react subpath:

import { VibeView } from '@scriptx-com/vibeview-sdk/react';

function SimulatorDemo() {
  return (
    <VibeView
      apiUrl="https://vibeview.io/api/v1"
      deviceType="ios"
      token="your-auth-token"
      autoStart={true}
      style={{ width: 375, height: 812 }}
    />
  );
}

While the connection to the device is down (a phone browser drops it when the tab goes to the background), <VibeView> covers the screen with “Reconnecting…”, then “Connection lost” and a Reconnect button if it gives up. Touches do nothing until it is back. Pass showReconnectingOverlay={false} to draw your own from the connection:state and connection:failed events. The client reconnects on its own as soon as the tab is visible again or the network returns; client.reconnect() starts a new attempt at any time.

React is an optional peer dependency. The SDK works without React installed — the core @scriptx-com/vibeview-sdk import has no React dependency.

Vanilla JS Usage

Use the VibeViewClient class directly when working outside React:

import { VibeViewClient } from '@scriptx-com/vibeview-sdk';

const client = new VibeViewClient('#simulator-container', {
  apiUrl: 'https://vibeview.io/api/v1',
  deviceType: 'ios',
  token: 'your-auth-token',
  autoStart: true,
});

await client.ready();

client.on('session:started', (session) => {
  console.log('Session started:', session.sessionId);
});

The first argument is a CSS selector string or an HTMLElement reference where the simulator will be rendered.

There is also a convenience helper that creates the client and waits for it to be ready in one call:

import { vibeview } from '@scriptx-com/vibeview-sdk';

const client = await vibeview('#container', {
  apiUrl: 'https://vibeview.io/api/v1',
  deviceType: 'android',
  autoStart: true,
});

Configuration

Pass a configuration object when creating a client. All properties are optional.

PropertyTypeDefaultDescription
apiUrlstringhttps://vibeview.ioBackend API URL. Set it to https://vibeview.io/api/v1: the default does not reach the API.
wsUrlstringwss://vibeview.ioWebSocket URL for streaming.
tokenstring—Bearer token for authentication.
sessionIdstring—Connect to an existing session instead of creating a new one.
deviceType'ios' | 'android' | 'roku'—Device platform to launch. For TV, combine with deviceCategory: 'tv' (Apple TV = 'ios' + 'tv'; Android TV = 'android' + 'tv'). 'roku' streams a Roku device.
deviceCategory'phone' | 'tablet' | 'tv'omitted = any handheldDevice form factor. Omit to allocate any handheld (any phone or tablet); pass 'tv' for Apple TV / Android TV sessions, or 'phone'/'tablet' to narrow.
deviceIdstring—Request a specific device by ID.
autoStartbooleanfalseStart the session immediately on initialization.
scalenumber | 'auto''auto'Device scale factor (10—100), or 'auto' to fit the container.
screenOnlybooleanfalseShow only the screen without device chrome.
deviceColor'black' | 'white''black'Device chrome color.
orientation'portrait' | 'landscape''portrait'Initial device orientation.
displayRotation0 | 90 | 180 | 2700Visual rotation (degrees clockwise) the host applies to the canvas. The SDK inverse-transforms taps so they still land on the correct device pixels. Useful when displaying a landscape-locked app upright inside a portrait canvas.
readOnlybooleanfalseDisable user interactions (view-only mode).
decoder'webcodecs' | 'mse''webcodecs'Video decoder. A browser without WebCodecs, or whose WebCodecs refuses the stream, uses 'mse' whatever you set here.
enableAdaptiveQualitybooleantrueAutomatically adjust bitrate/FPS quality tiers to match network conditions.
debugbooleanfalseEnable debug logging.
classNamestring—Custom CSS class for the container element.
stylePartial<CSSStyleDeclaration>—Inline styles for the container element.

Canvas Options

The canvas property accepts an object for fine-tuning rendering:

PropertyTypeDefaultDescription
acceleratedbooleantrueUse hardware acceleration.
imageSmoothingEnabledbooleantrueEnable image smoothing when scaling.

Events

The client emits events you can listen to with client.on():

client.on('session:status', (status) => {
  /* pending, starting, active, stopped, failed */
});
client.on('session:started', (session) => {
  /* session info with sessionId, deviceType, etc. On iPhone and iPad
     sessions, session.displayMetrics gives the device's screen size in
     points, its corner radii and the frame style the player uses. On a
     foldable it also carries both screens (panels.cover, panels.inner) and
     posture_ranges: which posture each hinge angle reads as on that device. */
});
client.on('session:failed', (error) => {
  /* Error object */
});
client.on('session:ended', (info) => {
  /* session stopped; info?.reasonCode says why (e.g. 'inactivity_timeout', 'stopped' when it was stopped from another tab, the CLI or the API, 'stopped_by_admin' when VibeView support ended it, 'worker_lost' when the device stopped responding, 'device_crashed' when the device stopped unexpectedly, 'device_turned_off' or 'device_restarted' when someone turned the device off or restarted it from its own menu, 'video_lost' when a TV device's video signal was lost and couldn't be restored, 'device_storage_limit' when the device ran out of its storage allowance, 'confined_app_lost' when an embedded app kept closing or leaving the screen and couldn't be brought back, 'partner_account_suspended' / 'partner_account_deleted' when the account the session belongs to was suspended or deleted, or 'app_unavailable' when the app it was started on is no longer shared with its account). Treat an unknown code as a plain end. */
});
client.on('timeout_warning', (secondsRemaining, reason) => {
  /* the session is about to end. reason is 'inactivity' (unused for the
     idle timeout), 'session_length_limit', 'usage_credit_exhausted',
     'overage_disabled' or 'device_storage_limit'; it may be missing, which
     means inactivity. It repeats
     with an updated secondsRemaining while the warning stands */
});
client.on('session:timeout-cleared', (reason) => {
  /* a timeout_warning was withdrawn. reason names which one: missing or
     'inactivity' when the session was used again, or 'usage_credit_exhausted' /
     'overage_disabled' when enough usage credit arrived to cancel that cutoff,
     or 'device_storage_limit' when files were deleted from the device in time.
     Any other pending warning still stands. A 'session_length_limit' warning
     is never withdrawn */
});
client.on('stream:started', () => {
  /* video frames arriving */
});
client.on('stream:stopped', () => {
  /* video stream ended */
});
client.on('stream:frame', (frameCount) => {
  /* a video frame was received (for custom rendering) */
});
client.on('stream:dimensions', ({ width, height }) => {
  /* video dimensions changed, e.g. after rotation, or when an Android
     foldable switches between its cover and inner screens */
});
client.on('device:dimensions', ({ width, height }) => {
  /* the size touches and UI element rects are measured in.
     On iPhone, iPad and Apple TV the video is sized to your player and can
     be smaller than the device, so this can differ from stream:dimensions */
});
client.on('render:no-gpu', () => {
  /* this browser draws without graphics acceleration (turned off, or the
     graphics card can't be used), so the device can look choppy. At most once,
     soon after the player starts (it can take up to about 15 seconds);
     client.rendersWithoutGpu() answers the same for a listener added later.
     Sent by Chromium-based browsers and Firefox on a computer; elsewhere only
     when WebGL runs in software. Not sent with decoder: 'mse'. A good moment
     to suggest turning hardware acceleration on. */
});
client.on('connection:state', (state) => {
  /* connecting, connected, disconnected, reconnecting, error */
});
client.on('connection:failed', () => {
  /* reconnection gave up after all retry attempts;
     call client.reconnect() to try again */
});
client.on('error', (error) => {
  /* general error */
});
client.on('device:orientation', (orientation) => {
  /* 'portrait' | 'portrait_upside_down' | 'landscape_left' | 'landscape_right' — iOS only */
});
client.on('device:posture', ({ posture, angle, display, waypoint }) => {
  /* 'closed' | 'partial' | 'open', the hinge angle in degrees, and the
     resulting display size — foldable devices only, fires on every fold
     or unfold regardless of what triggered it (this client, another
     client on the same session, the AI agent, or the `posture=` launch
     param). `waypoint` is true when the device switched screens partway
     through a fold that is still moving; the fold's final report follows */
});
client.on('device:hinge-target', ({ angle, drag }) => {
  /* iPhone Duo only: the angle the hinge is moving to, sent as soon as a fold
     is asked for (by anyone on the session) and with each frame of a hinge
     drag (`drag: true`), so you can animate the fold before the device
     reports it. `angle` is null when a fold stopped short: the last
     `device:posture` is where the device is. The next settled
     `device:posture` ends the move */
});
client.on('device:posture-error', ({ message }) => {
  /* fires when the device could not reach the requested posture; carries a
     `message` you can show */
});
client.on('deep-link:refused', (message, reason) => {
  /* openDeepLink did not open the link. `message` explains why and can be
     shown as-is; `reason` is 'refused' (the link was not allowed) or
     'failed' (the device could not open it) */
});
client.on('device:settings', ({ settings }) => {
  /* a setDeviceSettings / setAppearance change was applied on the device */
});
client.on('device:settings-error', ({ message, settings }) => {
  /* the device did not apply it; `message` can be shown as-is and
     `settings` is the change it answers */
});

The React component takes the two timeout events as props: onTimeoutWarning(secondsRemaining, reason) and onTimeoutCleared(reason). It takes device:dimensions as onDeviceDimensions({ width, height }).

Device Control

The client exposes programmatic device control alongside direct user interaction. All methods require an active session.

await client.tap(160, 320);
await client.swipe(160, 600, 160, 200, 300);
await client.typeText('hello@example.com');
MethodDescription
getDeviceSize()The size coordinates are measured in, as { width, height }, or null until the stream has shown a picture. On iPhone, iPad and Apple TV the video is sized to your player, so it can be smaller than this.
tap(x, y)Tap at coordinates, measured in getDeviceSize().
swipe(x1, y1, x2, y2, duration?)Swipe from one point to another; duration in milliseconds (default 500).
typeText(text)Type a full string as a single command.
type(text)Legacy variant: sends the string character by character.
pressKey(keycode)Press a hardware key (Android/TV), e.g. 'BACK', 'HOME', 'DPAD_UP', 'DPAD_CENTER'.
pressButton(button)Press an iOS hardware button, e.g. 'HOME', 'LOCK'.
rotate(degrees?)Rotate the device; 90, 180, or 270 (default 90). On the iPhone Duo it works in any posture and turns the device clockwise by degrees (270 turns it back a quarter); an Android foldable rotates like a phone, in any posture. On a foldable, device:posture reports how the device is now held as deviceOrientation.
setLocation(lat, lon)Set the simulated GPS location.
shake()Shake the device once (phones, tablets and foldables; not TV). A call within 4 seconds of the last one is ignored.
setAppearance(mode)Switch the device between 'light' and 'dark' appearance.
setDeviceSettings(settings)Change several device settings at once, e.g. { mode: 'dark', textSize: 9, reduceMotion: true }. Only the settings you pass change; check session.deviceCapabilities for what the device supports. Resolves once the request is sent — listen for 'device:settings' (applied) or 'device:settings-error' (not applied). When several changes arrive faster than the device applies them, it ends on the latest value of each setting.
setContentSize(size)Set the system text size: 'extra-small', 'small', 'medium', 'large', or 'extra-large'.
setIncreaseContrast(enabled)Turn the system’s higher-contrast rendering on or off (iOS only).
setStatusBar(preset)'clean' shows the App Store screenshot status bar (9:41, full battery, full signal); 'default' restores the device’s own (iOS phones and tablets only).
setAnimations(enabled)Turn the device’s system animations and transitions on or off (Android only). Sessions start with them off.
setPosture({ posture? , angle? })Fold or unfold a foldable device. Pass a preset posture ('closed', 'partial', 'open'), an exact angle in degrees (0–180), or both — angle wins when both are given. No-op with an error on a non-foldable device. The posture a device reports for an angle follows its own device-defined ranges, which session.displayMetrics.posture_ranges lists (see Foldable devices). Fire-and-forget, like the other setters above; listen for 'device:posture' on success or 'device:posture-error' if the device could not get there.
setHingeAngle(angle)Move a foldable device’s hinge toward angle (0–180 degrees) while the user drags a slider. The hinge follows each angle as it arrives, so you can call this as often as every animation frame. Nothing is acknowledged: when the drag ends, call setPosture({ angle }) once with the final angle. That call settles the device and reports 'device:posture' or 'device:posture-error'. While the drag is in progress, 'device:posture' can still fire if the device switches screens, and on the iPhone Duo every client on the session receives 'device:hinge-target' up to 25 times a second with the angle the hinge is moving to. An angle outside 0–180, or one that is not a finite number, throws a RangeError. The call is ignored before connect, on a read-only client, and on a non-foldable device.
openDeepLink(url)Open a link the app under test registers a URL scheme for, e.g. 'atlas://saved'. An app must be installed; links it does not handle, and links that would leave it, are refused. Listen for 'deep-link:refused' to learn why.
screenshot(options?)Capture the current frame; returns a data-URL string. Options: format ('png' default, 'jpeg', 'webp'), quality (0–1, default 0.92) and frame ('rendered' default: upright, turned as the viewer sees a rotated device; 'source': the stream’s own frame).
installApp(options)Install an app into the session. Pass file (a File/Blob) or url (downloaded first), plus optional launchAfterInstall (default false).

Custom presentation

If you want to present the stream yourself — for example painting it onto a 3D model — the client hands you its live picture and takes touches back.

MethodDescription
getRenderSurface()The live element the device picture is drawn into, ready to use as a texture or copy source. null before the session connects and after destroy(). It stays the client’s to manage — read from it, don’t detach or resize it. This is the supported way to read the picture: a canvas found in the page yourself may not hold the latest frame.
injectPointer(kind, x, y, options?)Drive a touch as though the user had pointed at that surface: 'down', then any number of 'move's, then 'up' (or 'cancel' to abandon the gesture, which lifts at the last position and ignores x/y). x and y are pixels within the surface, measured as it is displayed — after any displayRotation. If you draw the picture yourself and never rotate the element, pass { frame: 'source' } so the position is taken in the picture’s own orientation instead. Ignored before connect, after destroy(), on a read-only client, and on TV sessions.

TV devices

On TV sessions (Apple TV / Android TV), interaction is focus-based — the platform walks the d-pad focus to the target element instead of tapping coordinates:

MethodDescription
tapFocusedTv(locator)Move d-pad focus to the element matching the locator and press SELECT to activate it.
focusElementTv(locator)Move d-pad focus to the element without activating it.

Both take a locator object with any of accessibilityId, resourceId, text, and rect ({ x, y, width, height }). Both are fire-and-forget: they resolve when the command is sent, not when the walk completes.

Live keyboard

For live typing from a physical keyboard (as opposed to programmatic typeText), the client sends each keystroke to the device as it is pressed:

MethodDescription
liveType(char)Type a single printable character into the focused field.
liveKey(keycode)Press 'RETURN' or 'BACKSPACE'.
liveKeyCombo(key, modifiers)iPhone/iPad on iOS 18 or later: press an editing or caret-movement key combination, for example liveKeyCombo('V', ['meta']) or liveKeyCombo('ARROW_LEFT', ['shift', 'alt']). Keys: A, C, V, X, Z, ARROW_LEFT/RIGHT/UP/DOWN, TAB, ESCAPE, BACKSPACE, FORWARD_DELETE; modifiers: meta, shift, alt. Combinations outside this editing set are refused by the device.

Stream Stats

Inspect stream health and negotiated quality:

MethodDescription
getStreamStats()Current decoder statistics: { fps, bitrateKbps, framesDecoded, framesDropped, decodeErrors, decoderState, decoderType }, or null before the stream starts. bitrateKbps covers the last second and is null when there is nothing in that second to measure. Works with both WebCodecs and MSE decoders.
getPreferredCodec()The video codec in use. Always 'h264'.
rendersWithoutGpu()true once the client knows this browser draws without graphics acceleration (see the render:no-gpu event), else false.
getQualityTier()The name of the current adaptive-quality tier.

Cleanup

Call destroy() when you are done with a client instance:

client.destroy();

The destroy() method is idempotent — it checks an internal this.destroyed flag and returns immediately if the client has already been destroyed. This means it is safe to call destroy() multiple times, for example in both a cleanup handler and a component unmount.

Internally, destroy() closes the WebSocket connection, stops video decoding, removes all event listeners, and clears the container element.

Browser Compatibility

Check whether the current browser supports the SDK before rendering:

import { isSupported, getCompatibilityInfo } from '@scriptx-com/vibeview-sdk';

if (!isSupported()) {
  const info = getCompatibilityInfo();
  console.warn(info.recommendation);
}

The SDK requires WebCodecs or MSE with H.264, plus WebSocket and Canvas support. It uses WebCodecs where it can and moves to MSE by itself where it can’t.

On MSE a foldable shows a flat frame instead of the 3D model, and the stream is less sharp when shown smaller than its full size.

If a browser can’t play the stream, the player shows a message telling the viewer to update or use a current browser. The client emits stream:unsupported (onStreamUnsupported on <VibeView>), and in a browser with no decoder at all startSession() and connectToSession() reject, so no session starts. A browser can also refuse a stream only once it is playing. The event then fires while the session is running, and ending that session is up to you.

Any other failure to start the player is an ordinary error: error fires, ready() rejects, and <VibeView> calls onInitFailed so you can drop your own starting state.

Backward Compatibility

Within a major version the SDK stays backward compatible: published exports are never removed or renamed, and if a type or function needs to change, a new export is added alongside the existing one. Removing or renaming an export only happens in a new major version.

Version 2.0.0 removed test recording and in-browser playback from the SDK. That includes the recording, playback, step-marker and undo methods, the element-at-point lookups (requestUIElementAtPoint(), findElementAt(), resolveElement()), flushKeyboardBuffer(), the screen-stability helpers (waitForStable() and the hashing utilities), the interaction, interaction:enhanced, recording:buffer and ui:point-resolved events, and in React the onInteraction prop and the matching VibeViewRef members. See the SDK’s CHANGELOG.md for the full list. Live control (touches, keys, typing, the TV remote and settings) is unchanged. Tests are now written as steps on the Tests page (see AI Testing).

Tips

  • Use autoStart: true for demos where you want the simulator to appear immediately.
  • Use readOnly: true for presentation or documentation contexts where viewers should not interact with the device.
  • Use screenOnly: true to remove device chrome and show just the simulator screen, which is useful for tight layouts.
  • The sessionId option lets you connect multiple clients to the same running session, which is useful for shared viewing scenarios.
  • After changing SDK source types locally, rebuild with cd sdk && yarn build before consuming the updated package.

Last updated 27 Nov 2026 Something wrong on this page? Tell us

Search the docs