Webviews
Embed web content inside one of your windows. Unlike Windows (native OS windows), a webview is a rectangle of web content layered over a host window — use it to wrap third-party pages (an OAuth screen, an in-app browser) in your own chrome (a back button, a URL bar) instead of navigating the window away.
Each webview lives inside exactly one host window, is identified by a webviewId, and can be positioned either at fixed pixel coordinates (bounds) or auto-filling the host window with insets (fill).
Embedded content is untrusted. The webview does NOT receive the Deskifier SDK and cannot call sensitive commands. Even when the host↔webview message channel is enabled, the webview gets no capability access — it can only send messages up to the host, which runs the actual logic.
Methods
Create Webview
Creates a webview inside a host window.
await window.deskifier.webviews.create({ arguments })
Arguments
hostWindowIdString (Optional)
The window to attach the webview to. Defaults to the calling window.urlString (Optional)
Remote URL to load. Provide eitherurlorhtml.htmlString (Optional)
Inline app-owned HTML (loaded via adata:URL) — no hosting needed. Provide eitherurlorhtml.boundsDeskifier.WebviewBounds (Optional)
Fixed pixel rectangle inside the host window. Provide eitherboundsorfill.fillDeskifier.WebviewInsets (Optional)
Cover the host window inset by these edges — great for laying content "below a 40px bar". The webview auto-resizes with the window.backgroundColorString (Optional)
CSS color used for the webview background while its page loads.messagingBoolean (Optional)
Enable the host↔webview message channel (postMessage/onMessage). See the trust-model callout below before turning this on. Default isfalse.
Only enable messaging: true for content you trust to talk to your app (e.g. your own UI). A third-party page (like an OAuth screen) should be left off so it gets no bridge at all. Even with messaging on, the webview has no capability access — it can only message the host.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.webviewIdString
The ID of the new webview.
Example
const { webviewId } = await window.deskifier.webviews.create({
url: 'https://accounts.google.com/o/oauth2/v2/auth?...',
fill: { top: 40 }, // sits below your 40px header bar
backgroundColor: '#ffffff',
});
console.log(webviewId); // "webview-1"
Navigation
Load URL
Navigates the webview to a URL.
await window.deskifier.webviews.loadURL({ arguments })
Arguments
webviewIdString (Required)urlString (Required)
Returns
successBooleanmessageString
Go Back
Goes back one step in the webview's history. No-op if it can't.
await window.deskifier.webviews.goBack({ arguments })
Arguments
webviewIdString (Required)
Returns
successBooleanmessageString
Go Forward
Goes forward one step in the webview's history. No-op if it can't.
await window.deskifier.webviews.goForward({ arguments })
Arguments
webviewIdString (Required)
Returns
successBooleanmessageString
Reload
Reloads the webview's current page.
await window.deskifier.webviews.reload({ arguments })
Arguments
webviewIdString (Required)
Returns
successBooleanmessageString
Stop
Stops the current load.
await window.deskifier.webviews.stop({ arguments })
Arguments
webviewIdString (Required)
Returns
successBooleanmessageString
Layout
Set Bounds
Repositions or resizes a webview. Pass either bounds (fixed pixels) or fill (auto-resizing insets).
await window.deskifier.webviews.setBounds({ arguments })
Arguments
webviewIdString (Required)boundsDeskifier.WebviewBounds (Optional)
Fixed pixel rectangle inside the host window.fillDeskifier.WebviewInsets (Optional)
Cover the host window inset by these edges — auto-resizes with the window.
Returns
successBooleanmessageString
Show Webview
Shows a webview without destroying it.
await window.deskifier.webviews.show({ arguments })
Arguments
webviewIdString (Required)
Returns
successBooleanmessageString
Hide Webview
Hides a webview without destroying it. Its state (loaded page, scroll position, history) is preserved.
await window.deskifier.webviews.hide({ arguments })
Arguments
webviewIdString (Required)
Returns
successBooleanmessageString
Cleanup
Destroy Webview
Destroys a webview and removes it from its host window.
await window.deskifier.webviews.destroy({ arguments })
Arguments
webviewIdString (Required)
Returns
successBooleanmessageString
Messaging
Host↔webview messaging is opt-in — the webview must have been created with messaging: true. See the trust-model note under Create Webview.
The channel is deliberately narrow: the webview can only broadcast events / publish state to your host page. Your host (which HAS the full SDK) decides what to do with them.
Post Message
Sends a message down to a webview's page. The webview receives it via window.deskifier.webview.onMessage inside its own runtime.
await window.deskifier.webviews.postMessage({ arguments })
Arguments
webviewIdString (Required)dataAny (Required)
Any JSON-serializable value.
Returns
successBooleanmessageString
On Message
Receives messages a webview posts up (via window.deskifier.webview.postMessage inside the webview). Use msg.webviewId to tell which webview it came from. Returns an unsubscribe function.
const unsubscribe = window.deskifier.webviews.onMessage((msg) => {
// msg.webviewId — which webview sent it
// msg.data — the message payload
});
Arguments (passed to your handler)
webviewIdStringdataAny
Returns
UnsubscribeFunction
Call to stop listening.
Events
On Event
Subscribe to navigation and lifecycle events for webviews. One handler receives events for every webview — filter by event.webviewId. Returns an unsubscribe function.
const unsubscribe = window.deskifier.webviews.onEvent((event) => {
if (event.webviewId !== myWebviewId) return;
if (event.type === 'did-navigate') {
console.log('navigated to', event.url);
}
});
Arguments (passed to your handler)
webviewIdString
Which webview fired the event.typeString
One ofdid-navigate,did-fail-load,page-title-updated,loading.urlString (Optional)
Populated ondid-navigateanddid-fail-load.canGoBackBoolean (Optional)
Populated ondid-navigate— mirror this into your back-button's disabled state.canGoForwardBoolean (Optional)
Populated ondid-navigate.titleString (Optional)
Populated onpage-title-updated.loadingBoolean (Optional)
Populated onloading—truewhen a load starts,falsewhen it finishes.codeNumber (Optional)
Populated ondid-fail-load— Chromium error code.descriptionString (Optional)
Populated ondid-fail-load— human-readable error description.
Returns
UnsubscribeFunction
Call to stop listening.
Objects
WebviewBounds
xNumber
X coordinate (pixels) inside the host window.yNumber
Y coordinate (pixels) inside the host window.widthNumber
Width in pixels.heightNumber
Height in pixels.
WebviewInsets
All fields optional; each defaults to 0. The webview fills the host window inset by these edges and auto-resizes with the window.
topNumber (Optional)rightNumber (Optional)bottomNumber (Optional)leftNumber (Optional)