See how Capacitor fits into the entire Ionic Ecosystem ->
Capacitor is part of the Ionic Ecosystem ->
pwaiosandroid

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

Param Type
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

Param Type
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
Param Type
eventName "browserFinished"
listenerFunc (info: any) => void

Returns: PluginListenerHandle


addListener(…)

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

Returns: PluginListenerHandle


removeAllListeners()

removeAllListeners() => void

Remove all native listeners for this plugin


Interfaces

BrowserOpenOptions

Prop Type Description
url string The URL to open the browser to
windowName string Web only: Optional target for browser open. Follows the target property for window.open. Defaults to _blank
toolbarColor string A hex color to set the toolbar color to.
presentationStyle "fullscreen" | "popover" iOS only: The presentation style of the browser. Defaults to fullscreen.

BrowserPrefetchOptions

Prop Type
urls string[]

PluginListenerHandle

Prop Type
remove () => void
Previous
<- Background Task
Next
Camera ->
Contribute ->