Expo Web Browser provides access to the system's web browser and supports handling redirects for React Native and Expo applications. It offers platform-specific implementations using SFSafariViewController and ASWebAuthenticationSession on iOS, and ChromeCustomTabs on Android, ensuring native browser experiences while maintaining security and performance.
npx expo install expo-web-browser or npm install expo-web-browserimport * as WebBrowser from 'expo-web-browser';For specific imports:
import {
openBrowserAsync,
openAuthSessionAsync,
WebBrowserOpenOptions,
WebBrowserAuthSessionResult
} from 'expo-web-browser';CommonJS:
const WebBrowser = require('expo-web-browser');import * as WebBrowser from 'expo-web-browser';
// Open a simple web page
const result = await WebBrowser.openBrowserAsync('https://example.com');
// Open authentication session with redirect handling
const authResult = await WebBrowser.openAuthSessionAsync(
'https://accounts.google.com/oauth/authorize?...',
'myapp://redirect'
);
if (authResult.type === 'success') {
console.log('OAuth success, redirect URL:', authResult.url);
}Expo Web Browser is built around platform-specific browser implementations:
Core browser functionality for opening web pages and managing browser sessions. Perfect for displaying content like privacy policies, terms of service, or general web content.
function openBrowserAsync(
url: string,
browserParams?: WebBrowserOpenOptions
): Promise<WebBrowserResult>;
function dismissBrowser(): Promise<{ type: WebBrowserResultType.DISMISS }>;Secure authentication session management with proper redirect handling for OAuth flows. Designed for authentication workflows that require secure token exchange and proper session isolation.
function openAuthSessionAsync(
url: string,
redirectUrl?: string | null,
options?: AuthSessionOpenOptions
): Promise<WebBrowserAuthSessionResult>;
function dismissAuthSession(): void;
function maybeCompleteAuthSession(
options?: WebBrowserCompleteAuthSessionOptions
): WebBrowserCompleteAuthSessionResult;Android-specific Custom Tabs optimization features for improved performance and user experience. These functions provide fine-grained control over Custom Tabs lifecycle.
function getCustomTabsSupportingBrowsersAsync(): Promise<WebBrowserCustomTabsResults>;
function warmUpAsync(browserPackage?: string): Promise<WebBrowserWarmUpResult>;
function mayInitWithUrlAsync(
url: string,
browserPackage?: string
): Promise<WebBrowserMayInitWithUrlResult>;
function coolDownAsync(browserPackage?: string): Promise<WebBrowserCoolDownResult>;enum WebBrowserResultType {
CANCEL = 'cancel',
DISMISS = 'dismiss',
OPENED = 'opened',
LOCKED = 'locked'
}
enum WebBrowserPresentationStyle {
FULL_SCREEN = 'fullScreen',
PAGE_SHEET = 'pageSheet',
FORM_SHEET = 'formSheet',
CURRENT_CONTEXT = 'currentContext',
OVER_FULL_SCREEN = 'overFullScreen',
OVER_CURRENT_CONTEXT = 'overCurrentContext',
POPOVER = 'popover',
AUTOMATIC = 'automatic'
}
interface WebBrowserResult {
type: WebBrowserResultType;
}
interface WebBrowserRedirectResult {
type: 'success';
url: string;
}
type WebBrowserAuthSessionResult = WebBrowserRedirectResult | WebBrowserResult;
interface AuthSessionOpenOptions extends WebBrowserOpenOptions {
preferEphemeralSession?: boolean;
}
interface WebBrowserCompleteAuthSessionOptions {
skipRedirectCheck?: boolean;
}
interface WebBrowserCompleteAuthSessionResult {
type: 'success' | 'failed';
message: string;
}
type WebBrowserWindowFeatures = Record<string, number | boolean | string>;
type RedirectEvent = {
url: string;
};