Skip to main content

expo-web-browser

Version: 55.0.6 Provides access to the system’s web browser and supports handling redirects. Uses SFSafariViewController on iOS and Chrome Custom Tabs on Android.

Installation

npx expo install expo-web-browser

Usage

import * as WebBrowser from 'expo-web-browser';

// Open URL
await WebBrowser.openBrowserAsync('https://expo.dev');

// For OAuth flows
WebBrowser.maybeCompleteAuthSession();

// Open with auth
const result = await WebBrowser.openAuthSessionAsync(
  'https://myapp.com/auth',
  'myapp://redirect'
);

API Reference

Methods

openBrowserAsync(url, options)
(url: string, options?: WebBrowserOpenOptions) => Promise<WebBrowserResult>
Opens URL in browser
const result = await WebBrowser.openBrowserAsync('https://expo.dev', {
  controlsColor: '#00ff00',
  toolbarColor: '#000000',
});
openAuthSessionAsync(url, redirectUrl, options)
(url: string, redirectUrl?: string, options?: WebBrowserAuthSessionOptions) => Promise<WebBrowserAuthSessionResult>
Opens browser for auth
const result = await WebBrowser.openAuthSessionAsync(
  'https://auth.example.com/login',
  'myapp://oauth-callback'
);

if (result.type === 'success') {
  console.log('URL:', result.url);
}
dismissBrowser()
() => void
Dismisses open browser (iOS only)
WebBrowser.dismissBrowser();
warmUpAsync()
() => Promise<void>
Warms up browser (Android)
coolDownAsync()
() => Promise<void>
Cools down browser (Android)
maybeCompleteAuthSession()
() => void
Completes auth sessionCall at app root for OAuth flows:
WebBrowser.maybeCompleteAuthSession();

Platform Support

PlatformSupportedImplementation
iOSSFSafariViewController
AndroidChrome Custom Tabs
Webwindow.open

Resources