Tutorial: Platform.closeView


Closes a specified view in a target window.


let windowIdentity;
if (fin.me.isWindow) {
    windowIdentity = fin.me.identity;
} else if (fin.me.isView) {
    windowIdentity = (await fin.me.getCurrentWindow()).identity;
} else {
    throw new Error('Not running in a platform View or Window');

const viewOptions = {
    name: 'test_view',
    url: 'https://example.com'

function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));

const platform = await fin.Platform.getCurrent();

await platform.createView(viewOptions, windowIdentity);
// a new view will now show in the current window

await sleep(5000);

const viewIdentity = { uuid: windowIdentity.uuid, name: 'test_view'};
// the view will now close