Initializing the SDK
Hyperbeam(container, embedURL, options?): Promise<HyperbeamClient>
Use Hyperbeam(container, embedURL, options?)
to create an instance of the HyperbeamClient object. The HyperbeamClient object is your entrypoint to the rest of the Hyperbeam JavaScript SDK.
JavaScript
Method Parameters
The container can be either a
div
or an iframe
element, though it is
highly advised to use a div
.Initialization options. All properties are optional.
The HyperbeamClient object
The HyperbeamClient object allows you to programmatically control the virtual browser, set user permissions, and debug connection issues among other things.JavaScript
Properties
The client’s user ID. See
example.
The client’s admin token. See
example.
The local volume of the virtual browser. See
example.
The width of the virtual browser in pixels. See
example.
The height of the virtual browser in pixels. See
example.
The maximum virtual browser area that can be allocated in pixels. See
example.
Pauses the video stream of the virtual browser locally. See
example.
When
playoutDelay
= true
, input lag increases but smoothness is improved
and frame drops are reduced.The virtual browser Tabs object. See
example.
Methods
reconnect
hb.reconnect(): void
Useful in situations where you need to troubleshoot the browser disconnecting. See example.
destroy
hb.destroy(): void
Tears down network connections and browser events. Always call this before removing the container element from the page. See example.
addRoles
hb.addRoles(userIds, roles, exclusive): Promise<void>
Adds the list of roles to all the provided user ids.
Method parameters
List of user ids
List of roles to be assigned to the provided user ids
If set to true, the roles are assigned to all users except the provided list of user ids.
removeRoles
Removes the list of roles from all the provided user ids.
hb.removeRoles(userIds, roles, exclusive): Promise<void>
Sets the permission of a user by their ID. The client must have an admin token set to manage user permissions. See example.
Method parameters
List of user ids
List of roles to be removed from the provided user ids
If set to true, the roles are removed from all users except the provided list of user ids.
setPermissions
hb.setPermissions(userId, permissionData): Promise<void>
setPermissions
is deprecated, please use addRoles
and removeRoles
The user ID to set permissions for.
All keys can be omitted: if the key is omitted, then the existing value will
be unchanged.
sendEvent
hb.sendEvent(event): void
Sends a keyboard, mouse, or mouse wheel event to the Hyperbeam browser. See example.
Method parameters
resize
hb.resize(width, height): void
Resizes the virtual browser to the specified width and height, in pixels. The arguments must meet the following conditions, otherwise the function will throw a RangeError: width * height cannot be greater than hb.maxArea
.
hb.maxArea
is the maximum area that can be allocated in pixels.
See example.
Method parameters
The width of the virtual browser in pixels.
The height of the virtual browser in pixels.
ping
hb.ping(): void
Resets the inactive
timeout. Useful for situations where the user is not interacting with the Hyperbeam browser, but is performing actions on other parts of your application.
getRegionInfo
getRegionInfo(): Promise<HyperbeamRegionInfo>
The Hyperbeam Web SDK provides a function called getRegionInfo()
that returns a HyperbeamRegionInfo object. This object refers to the optimal region to spin up a virtual computer based on the client’s location.
JavaScript
HyperbeamRegionInfo
Properties
Two-letter region code.
Country code.