Programmatically launch HERE content
There are three functions to programmatically launch pre-configured content in the HERE Enterprise Browser: launchContent, launchSupertab, and launchWorkspace. Each launches a piece of existing content, applying the configuration and permissions an administrator previously defined for that content.
Each function takes a content ID as its first argument. This ID is the identifier an administrator assigns to a piece of content in the HERE Admin Console. The ID is unique across all content types, so a given ID resolves to exactly one app, supertab, or collection.
Launching by ID keeps code portable across environments since the same ID maps to the correct, environment-specific URL and configuration on each deployment.
Installation and import
All three functions are imported from the same npm package, @openfin/cloud-api.
npm install @openfin/cloud-api
or
yarn add @openfin/cloud-api
import { launchContent, launchSupertab, launchWorkspace } from '@openfin/cloud-api';
launchContent
Launches an individual app or site. This is the most flexible of the three functions and accepts an options object controlling where and how the content opens.
launchContent(contentId: string, options?: LaunchOptions): void;
LaunchOptions
| Field | Type | Description |
|---|---|---|
queryParams | Record<string, string> | Key/value pairs merged into the content's URL as a query string. |
bounds | { top: number; left: number; width: number; height: number } | Position and size of the new window. Used when launching into a new window. |
instanceMode | 'multi' | (others) | Controls instancing. 'multi' is shown in the example; it allows launching a new instance. |
targetType | 'window' | 'view' | Where to place the launched content. Omit to open in a new window. |
targetIdentity | Identity | The identity of the target window or view, required when targetType is set. |
launchContent launch modes
This example demonstrates three distinct ways to launch content with launchContent.
New window: omit targetType; optionally supply bounds:
launchContent(contentId, {
queryParams: { abc: '123' },
bounds: { top: 0, left: 500, width: 400, height: 400 },
instanceMode: 'multi'
});
New tab in an existing window — set targetType: 'window' and pass the target window's identity:
const view = window.fin.View.getCurrentSync();
const parentWindow = await view.getCurrentWindow();
launchContent(contentId, {
queryParams: { abc: '123' },
instanceMode: 'multi',
targetType: 'window',
targetIdentity: parentWindow.identity
});
In place of the current view — set targetType: 'view' and pass the current view's identity:
const view = window.fin.View.getCurrentSync();
launchContent(contentId, {
queryParams: { abc: '123' },
instanceMode: 'multi',
targetType: 'view',
targetIdentity: view.identity
});
Obtaining targetIdentity relies on the fin API (window.fin.View.getCurrentSync(), view.getCurrentWindow()), which provides the identity of the current view and its parent window.
launchSupertab
Launches an existing supertab (a collection of pages) by ID. As shown in the example, it takes only the ID and accepts no options.
launchSupertab(supertabId: string): void;
const pageId = pageIdInput.current?.value;
if (pageId) {
launchSupertab(pageId);
}
launchWorkspace
Launches a collection by ID. Like launchSupertab, it takes only the ID.
launchWorkspace(workspaceId: string): void;
const workspaceId = workspaceIdInput.current?.value;
if (workspaceId) {
launchWorkspace(workspaceId);
}
Example
This example reads an ID from input, guards against an empty value, and then calls the matching launch function.
function launchById(kind: 'content' | 'supertab' | 'workspace', id: string) {
if (!id) return;
switch (kind) {
case 'content':
launchContent(id, { instanceMode: 'multi' });
break;
case 'supertab':
launchSupertab(id);
break;
case 'workspace':
launchWorkspace(id);
break;
}
}