npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

unsocial

v1.2.0

Published

A lightweight React component that detects when users are viewing your site in social media apps

Readme

Unsocial

A lightweight React component that detects when users are viewing your website in social media apps' internal browsers (Facebook, Instagram, etc.) and shows a helpful popup encouraging them to open the page in their external browser for a better experience.

npm version TypeScript License: MIT

✨ Features

  • 🎯 Accurate Detection - Detects Facebook, Instagram, and other Meta app browsers
  • 🌙 Dark Mode Support - Automatically respects user's system theme preference
  • 📱 Mobile Optimized - Designed for mobile social media usage patterns
  • ♿ Accessible - Full ARIA support and semantic HTML
  • 🎨 Customizable - Custom text, styling, and behavior options
  • 📦 Lightweight - Minimal bundle size, no external dependencies, no CSS framework required
  • 🔧 TypeScript - Full type safety and IntelliSense support

🚀 Installation

pnpm add unsocial
npm install unsocial

📋 Requirements

  • React 17, 18, or 19

That's it. Styling is fully self-contained (inline styles), so no Tailwind or CSS setup is needed.

🛠️ Usage

Basic Usage

import { Unsocial } from "unsocial";

function App() {
  return (
    <div>
      <Unsocial />
      {/* Your app content */}
    </div>
  );
}

Custom Text

<Unsocial
  customText={{
    title: "Better Experience Available",
    description:
      "Open in your browser for full functionality and faster loading.",
    howToTitle: "Quick steps to open externally:",
    openInBrowserButton: "Open in Browser",
    continueButton: "Continue Here",
  }}
  showContinueButton={true}
/>

Hide the "Continue Here" Button

Force users toward the external browser by removing the continue option:

<Unsocial showContinueButton={false} />

Hook: Conditional Rendering

Some features don't work in in-app browsers (e.g. Google OAuth blocks embedded WebViews). Use the useSocialBrowser hook to show or hide anything based on detection:

import { useSocialBrowser } from "unsocial";

function LoginButtons() {
  const { isSocialBrowser, appName } = useSocialBrowser();

  return (
    <div>
      {!isSocialBrowser && <GoogleLoginButton />}
      <EmailLoginButton />
      {isSocialBrowser && <p>Google login unavailable in {appName}'s browser.</p>}
    </div>
  );
}

SSR-safe: returns false on the server and first client render, then updates after mount, so there is no hydration mismatch.

Debug Mode (for testing/development)

<Unsocial debugMode={true} />

Custom Styling

<Unsocial className="custom-popup-styles" />

🎛️ Props

| Prop | Type | Default | Description | | -------------------- | --------- | ------- | ---------------------------------------- | | className | string | "" | Additional CSS classes on the overlay | | customText | object | - | Custom text content (see below) | | showContinueButton | boolean | false | Show the "Continue Here" button | | debugMode | boolean | false | Always show popup for testing |

Custom Text Object

interface CustomText {
  title?: string; // Popup title
  description?: string; // Main description text
  howToTitle?: string; // Instructions title
  openInBrowserButton?: string; // Primary button text
  linkCopiedMessage?: string; // Message after copying the link
  continueButton?: string; // Continue button text
}

Exports

import Unsocial from "unsocial"; // default export
import { Unsocial } from "unsocial"; // named export
import { SocialBrowserDetector } from "unsocial"; // alias, same component
import { useSocialBrowser } from "unsocial"; // detection hook
import type { SocialBrowserDetectorProps } from "unsocial";

🔍 Detected Browsers

The component detects these social media in-app browsers:

  • Facebook App (iOS & Android)
  • Instagram App (iOS & Android)
  • Messenger (when using webview)
  • Other Meta family apps

🎨 Styling

The component ships with self-contained inline styles (no CSS framework needed) and automatically supports:

  • Light Mode - Clean, modern light theme
  • Dark Mode - Automatically enabled based on user's system preference
  • Responsive Design - Optimized for mobile devices

Dark Mode

Dark mode is automatically applied when the user's system is set to dark mode. No additional configuration needed!

🌐 Browser Support

  • ✅ iOS Safari (in-app)
  • ✅ Android Chrome (in-app)
  • ✅ Facebook iOS
  • ✅ Facebook Android
  • ✅ Instagram iOS
  • ✅ Instagram Android
  • ✅ All modern mobile browsers

📱 User Experience

When a social media browser is detected, users see:

  1. Clear explanation of why external browser is better
  2. Step-by-step instructions on how to open externally
  3. Option to continue in the current browser (can be disabled)
  4. Accessible design with proper focus management

On Android, the primary button opens the page directly in the default browser via an intent URL. On iOS, it copies the link so users can paste it into Safari.

🔧 Development

Local Development

git clone https://github.com/2u841r/unsocial
cd unsocial
pnpm install

Building

pnpm build

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙋 Support

⭐ Show your support

Give a ⭐️ if this project helped you!


Why is this needed?

Social media apps use internal browsers that often have limited functionality, slower performance, and restricted features compared to external browsers. This component helps improve user experience by guiding users to open your website in their preferred browser where they can enjoy:

  • Faster loading times
  • Full browser features
  • Better security
  • Proper bookmark/sharing functionality
  • Complete JavaScript/CSS support

Made with ❤️ for better web experiences