Skip to main content
Version: v2

Browser

The Browser API makes it easy to open an in-app browser session to show external web content, handle authentication flows, and more.

On iOS this uses SFSafariViewController and is compliant with leading oAuth service in-app-browser requirements.

import { Plugins } from '@capacitor/core';

const { Browser } = Plugins;

await Browser.open({ url: 'http://capacitorjs.com/' });

API

open(...)

open(options: BrowserOpenOptions) => Promise<void>

Open a page with the given URL

ParamType
options
BrowserOpenOptions

prefetch(...)

prefetch(options: BrowserPrefetchOptions) => Promise<void>

Hint to the browser that the given URLs will be accessed to improve initial loading times.

Only functional on Android, is a no-op on iOS

ParamType
options
BrowserPrefetchOptions

close()

close() => Promise<void>

Close an open browser. Only works on iOS and Web environment, otherwise is a no-op


addListener(...)

addListener(eventName: 'browserFinished', listenerFunc: (info: any) => void) => PluginListenerHandle
ParamType
eventName"browserFinished"
listenerFunc(info: any) => void

Returns:

PluginListenerHandle


addListener(...)

addListener(eventName: 'browserPageLoaded', listenerFunc: (info: any) => void) => PluginListenerHandle
ParamType
eventName"browserPageLoaded"
listenerFunc(info: any) => void

Returns:

PluginListenerHandle


removeAllListeners()

removeAllListeners() => void

Remove all native listeners for this plugin


Interfaces

BrowserOpenOptions

PropTypeDescription
urlstringThe URL to open the browser to
windowNamestringWeb only: Optional target for browser open. Follows the target property for window.open. Defaults to _blank
toolbarColorstringA hex color to set the toolbar color to.
presentationStyle"fullscreen" | "popover"iOS only: The presentation style of the browser. Defaults to fullscreen.

BrowserPrefetchOptions

PropType
urlsstring[]

PluginListenerHandle

PropType
remove() => void