Escape In-App Browser (EIAB): detect in-app browsers and generate external-browser escape URLs.
npm install eiabDetect in-app browsers and generate escape URLs to open the current page in an external browser.
| App | iOS | Android |
|-----|-----|---------|
| Facebook | ✅ | ✅ |
| Google Search App | ✅ | - |
| Instagram | ✅ | ✅ |
| LINE | ✅ | ✅ |
| LinkedIn | ✅ | - |
| Messenger | ✅ | ✅ |
| Snapchat | ✅ | - |
| Threads | ✅ | ✅ |
| TikTok | ✅ | ✅ |
| Twitter/X | ✅ | - |
| WeChat | ✅ | ✅ |
| WhatsApp | ✅ | ✅ |
| KakaoTalk | ✅ | ✅ |
``bash`
npm install eiabbun
Also supports , pnpm, and yarn. This library is ESM-only.
ts
import { attemptEscape } from "eiab";attemptEscape();
`$3
`tsx
import { EscapeInAppBrowser, useIsInAppBrowser, EiabSuccess, EiabFailed } from "eiab/react";export default function Layout({ children }) {
const inApp = useIsInAppBrowser(); // null during SSR, boolean after hydration
return (
<>
You're in a normal browser!
Please open this page in Safari or Chrome.
{children}
>
);
}
`API
-
isInAppBrowser(userAgent?: string): boolean — Returns true if the UA matches in-app browser patterns.
- getEscapeUrl(currentUrl?, userAgent?): string | null — Returns a URL/scheme to escape the in-app browser, or null.
- attemptEscape(currentUrl?, userAgent?): void — Convenience wrapper that redirects to the escape URL if detected.The
eiab/react entry point exports EscapeInAppBrowser, useIsInAppBrowser, EiabSuccess, and EiabFailed.
Notes
-
eiab` is intentionally small and dependency-free at runtime.