How to Detect an In-App Browser (User-Agent Guide)

5 min read · 2026-10-29

To detect an in-app browser, you check the browser's user-agent string for known identifiers that apps like Instagram, TikTok, Facebook, and LinkedIn inject when they open links inside their own embedded webview instead of Safari or Chrome. These identifiers — things like Instagram, FBAN, FBAV, or musical_ly — show up as substrings in navigator.userAgent and let your site branch logic accordingly.

This guide walks through exactly how in-app browser detection works, shows real code you can drop into a page today, and explains why user-agent sniffing alone won't actually get users into a real browser — and what will.

What Is an In-App Browser, and Why Does Detecting It Matter?

An in-app browser (sometimes called an in-app webview) is the stripped-down browser that social apps open when someone taps a link inside the app, instead of handing the link off to the phone's default browser. Instagram, TikTok, Facebook, LinkedIn, and Snapchat all do this.

These webviews cause real problems for creators and affiliate marketers:

That's why the first technical step in any in-app browser escape strategy is being able to detect in-app browser sessions reliably, so you can prompt the user (or automatically redirect them) to the device's default browser.

How to Detect an In-App Browser Using the User-Agent String

Every in-app browser appends its own signature to the standard user-agent string. You can read this in JavaScript with navigator.userAgent and run it against a list of known patterns.

Common in-app browser user-agent signatures

Basic detection script

Here's a minimal, dependency-free function to detect in-app browser traffic client-side:

function isInAppBrowser() { const ua = navigator.userAgent || navigator.vendor || window.opera; return /Instagram|FBAN|FBAV|Line\/|musical_ly|BytedanceWebview|LinkedInApp|Snapchat|Twitter/i.test(ua); }

You can extend this to identify the specific app, which matters because the escape behavior differs by platform:

function getInAppBrowserName(ua) { if (/FBAN|FBAV/i.test(ua)) return 'facebook'; if (/Instagram/i.test(ua)) return 'instagram'; if (/musical_ly|BytedanceWebview/i.test(ua)) return 'tiktok'; if (/LinkedInApp/i.test(ua)) return 'linkedin'; return null; }

This is the core technique behind nearly every "open in browser" prompt and every in-app browser escape tool, including the redirect layer that Vayda and similar smart-link platforms run before a user hits your landing page.

Why User-Agent Detection Alone Isn't Enough to Escape In-App Browsers

Detecting the in-app browser is step one. Getting the user out of it is a separate, harder problem, because in-app browsers are sandboxed webviews, not real browser instances:

We cover the Instagram-specific version of this problem in more depth in our guide to the Instagram in-app browser and its "open in browser" option, including why that menu item doesn't always appear.

How to Escape an In-App Browser Once You've Detected It

Once your script flags an in-app webview, you have two realistic options to break the user out into their default browser.

Android: the intent:// scheme

On Android, you can redirect using an intent:// URL, which tells the OS to launch the link in Chrome (or the user's default browser) directly, bypassing the webview:

intent://example.com/your-path#Intent;scheme=https;package=com.android.chrome;end

This works because intent:// is interpreted by the Android OS itself, not by the in-app webview, so it can hand control to a separate app.

iOS: universal links and their limits

iOS is more restrictive. Universal links and the older x-safari-https:// prefix can sometimes trigger a handoff to Safari, but Apple has tightened this behavior over various iOS versions, and in-app browsers frequently intercept the tap before the universal link fires. In practice, many iOS escapes rely on an interstitial page with a tappable "Open in Safari" button plus an automated attempt, rather than a single guaranteed redirect.

Why this needs ongoing maintenance

Because Instagram, TikTok, and Facebook update their webview behavior periodically, a detection-and-escape script that works today may need tweaks in a few months. This is the main reason many creators and affiliate marketers hand this off to a dedicated smart-link service rather than maintaining it themselves.

Testing Your In-App Browser Detection

Before trusting any script in production, verify it against the real apps:

A Simpler Alternative: Let a Smart Link Handle Detection For You

Writing and maintaining your own in-app browser detection and escape logic is doable, but it's ongoing work: tracking new UA patterns, testing Android intents, handling iOS fallbacks, and preserving your click tracking and UTM parameters through every redirect. Several smart-link tools, including Vayda and competitors like linktw.in, handle this detection-and-escape layer for you, along with geo- and device-based routing so the same link sends iPhone users to the App Store and Android users to Google Play automatically.

Vayda wraps your destination URL in a smart link that detects the in-app browser, routes the click to the native app or default browser, and keeps your tracking parameters intact end to end — so you don't have to maintain UA regex lists yourself.

Ready to stop losing clicks to in-app browsers? Create your free Vayda link and test the escape behavior on your own Instagram or TikTok traffic today.

Stop losing clicks to the in-app browser.
Vayda turns one link into a smart link that escapes Instagram, TikTok and Facebook webviews and opens the right app — with your tracking intact.
Create a free smart link

Frequently asked questions

How do you detect an in-app browser in JavaScript?

Check navigator.userAgent for known app identifiers such as 'Instagram', 'FBAN', 'FBAV', or 'musical_ly'. If any of these substrings appear, the page is loading inside that app's in-app browser rather than the device's default browser.

What is the user-agent string for Instagram's in-app browser?

Instagram's in-app browser appends 'Instagram' to the standard mobile user-agent string, for example alongside the normal iOS or Android Safari/Chrome UA. You can detect it with a simple case-insensitive match for 'Instagram' in navigator.userAgent.

Can you force a link to open outside an in-app browser?

On Android, an intent:// URL can hand the link to Chrome or the default browser directly. On iOS, universal links sometimes work, but Apple's restrictions mean many sites fall back to an 'Open in Safari' interstitial button instead of an automatic redirect.

Why does in-app browser detection need regular updates?

Instagram, TikTok, and Facebook periodically change their webview behavior and user-agent strings, so detection scripts that worked previously can stop matching correctly after an app update, which is why ongoing testing is necessary.