OpenFin

JavaScript API

API Docs Legacy Docs

Have you been using our legacy API under the fin.desktop object? Welcome to the new and improved V2 API! You can now access the same classes and methods directly on the fin object. Please read this explanation of the differences between the legacy V1 API and the new V2 API.

The JavaScript API allows you to create an HTML/JavaScript application that has access to the native windowing environment, can communicate with other applications and has access to sandboxed system-level features.

The fin namespace

When running within the OpenFin Runtime your web applications have access to the fin namespace and all the modules within the API without the need to include additional source files. You can treat the fin namespace as you would the window, navigator or document objects.

API Methods

The full API Method Index can be found here.

  • To find a specific method by name, open the link above and use the search feature.
  • To browse the API, click one of the classes or namespaces in the sidebar at left for detailed information.

Configuration

New applications and windows are instantiated with the following options objects:

For a single-page reference to all application settings and configuration options, see also our Application Configuration page.

Example:

<!DOCTYPE html>
<html>
<head>
    <title>OpenFin Template</title>
</head>

<body>
    <h1>Hello, world!</h1>
    <p>This is a template for an OpenFin application.</p>
    <p>Current version: <span id="of-version"></span></p>
    
    <script type="text/javascript">
        if (typeof fin !== 'undefined') {
            init();
        } else {
            document.querySelector('#of-version').innerText =
                'The fin API is not available - you are not running in OpenFin.';
        }

        //once the DOM has loaded and the OpenFin API is ready
        async function init() {
            //get a reference to the current Application & Window.
            const app = await fin.Application.getCurrent();
            const win = await fin.Window.getCurrent();

            const ofVersion = document.querySelector('#of-version');
            ofVersion.innerText = await fin.System.getVersion();

            //Only launch new windows from the main window.
            if (win.identity.name === app.identity.uuid) {
                // Subscribing to the run-requested events will allow us to
                // react to secondary launches.  For this app we will launch a
                // child window when the user first clicks on the desktop icon.
                app.once('run-requested', async () => {
                    await fin.Window.create({
                        name: 'childWindow',
                        url: location.href,
                        autoShow: true
                    });
                });
            }
        }
    </script>
</body>
</html>

JavaScript API


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.