# openInBrowser()

The `openInBrowser()` function opens a page of your web app in the device's default browser with the native app's user already signed in.

> On Android, the sign-in link opens in your app instead of the browser if your app has a verified App Link that matches it. The link's path is `/v1/session_transfers/redeem` on your Frontend API URL. The intent filter in the [passkeys setup](https://clerk.com/docs/expo/reference/passkeys.md) matches every path on that host, so it matches the link, and the user isn't signed in on the web.
>
> To fix this, narrow the intent filter with `pathPrefix` or `pathPattern` to the paths that your app handles, or remove it if your app doesn't open links on that host. Keep your Android app registered on the [**Native applications**](https://dashboard.clerk.com/~/native-applications) page, which serves the `assetlinks.json` file.

For setup steps, see [Open your web app signed in from a native app](https://clerk.com/docs/guides/development/native-to-web.md).

## Installation

On Android, this function requires `expo-intent-launcher` and `expo-application`. iOS doesn't need any extra packages.

filename: terminal
```bash
npx expo install expo-intent-launcher expo-application
```

Without `expo-intent-launcher`, the function rejects with the `missing_dependency` error code on Android.

Then, import the function from the `@clerk/expo/native-to-web` subpath:

```tsx
import { openInBrowser } from '@clerk/expo/native-to-web'
```

## Usage

`openInBrowser()` has the following function signature:

```ts
function openInBrowser(params: OpenInBrowserParams): Promise<void>
```

### Parameters

`openInBrowser()` accepts the following parameters (`OpenInBrowserParams`):

| Name        | Type   | Description                                                                                                                                                                   |
| ----------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| destination | string | The page to open, as an absolute URL. Outside development instances, it must use HTTPS. In production, it must share a root domain with one of your Clerk instance's domains. |

### Returns

`openInBrowser()` returns a `Promise` that resolves after it starts opening the sign-in link. It doesn't wait for the web page to sign the user in, and if the sign-in fails on the web, your app isn't notified. See [how to handle a failed sign-in on the web](https://clerk.com/docs/guides/development/native-to-web.md#handle-a-failed-sign-in-on-the-web).

The `Promise` rejects with a [SessionTransferError](https://clerk.com/docs/expo/reference/is-session-transfer-error.md#sessiontransfererror) when Clerk can't create the link, or when opening the link fails before the `Promise` resolves.

Overlapping calls for the same `destination` share one link, so a double tap opens one browser tab.

## Example

The following example opens the settings page of a web app when the user selects **Open on web**. A signed-out user goes to the sign-in screen instead.

filename: components/open-on-web-button.tsx
```tsx
import { isSessionTransferError, openInBrowser } from '@clerk/expo/native-to-web'
import { router } from 'expo-router'
import { Alert, Button } from 'react-native'

export function OpenOnWebButton() {
  const onPress = async () => {
    try {
      await openInBrowser({ destination: 'https://app.example.com/settings' })
    } catch (error) {
      if (isSessionTransferError(error) && error.code === 'signed_out') {
        router.replace('/sign-in')
        return
      }
      Alert.alert('Could not open the web app')
    }
  }

  return <Button title="Open on web" onPress={onPress} />
}
```

---

## Sitemap

[Overview of all docs pages](https://clerk.com/docs/llms.txt)
