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

@composio/is-browser-agent

v0.0.1

Published

Detect when your site is being opened from an AI-agent browser.

Readme

@composio/is-browser-agent

Detect when your site is being opened from an AI-agent browser.

Today this package detects Codex user agents. The API is intentionally small and typed so we can add more agent browsers later without changing app-side DX.

Install

pnpm add @composio/is-browser-agent
npm install @composio/is-browser-agent

Why

Some AI coding agents and agentic browsers visit normal web pages with their own user-agent token. If your app wants to offer an agent-native path — for example, redirecting Codex to agents.composio.dev or showing a special CTA — this package gives you one place to detect that safely.

Server-safe API

Use the root export anywhere you have a user-agent string: Next.js middleware, route handlers, server components, API routes, edge functions, or plain Node.

import { detectIsBrowserAgent } from "@composio/is-browser-agent";

const detection = detectIsBrowserAgent(request.headers.get("user-agent"));

if (detection.isBrowserAgent) {
  console.log(detection.agent.id); // "codex"
  console.log(detection.agent.name); // "Codex"
}

Next.js middleware example

import { NextResponse, type NextRequest } from "next/server";
import { detectIsBrowserAgent } from "@composio/is-browser-agent";

export function middleware(request: NextRequest) {
  const detection = detectIsBrowserAgent(request.headers.get("user-agent"));

  if (detection.isBrowserAgent && detection.agent.id === "codex") {
    return NextResponse.redirect("https://agents.composio.dev");
  }

  return NextResponse.next();
}

React hook

Use the React hook from the /react subpath. This entry is client-only.

"use client";

import { useIsBrowserAgent } from "@composio/is-browser-agent/react";

export function AgentSignupBanner() {
  const detection = useIsBrowserAgent();

  if (!detection.isBrowserAgent) return null;

  return (
    <aside>
      <p>Hello {detection.agent.name}.</p>
      <a href="https://agents.composio.dev">Sign up as an agent</a>
    </aside>
  );
}

Convenience helper

If you only care about Codex for now:

import { isCodexUserAgent } from "@composio/is-browser-agent";

if (isCodexUserAgent(userAgent)) {
  // Codex browser detected
}

Type safety

detectIsBrowserAgent returns a discriminated union:

type BrowserAgentDetection =
  | {
      isBrowserAgent: true;
      agent: {
        id: "codex";
        name: "Codex";
      };
    }
  | {
      isBrowserAgent: false;
      agent: null;
    };

That means TypeScript narrows automatically:

const detection = detectIsBrowserAgent(userAgent);

if (detection.isBrowserAgent) {
  detection.agent.id; // typed as "codex"
} else {
  detection.agent; // typed as null
}

API

detectIsBrowserAgent(userAgent)

function detectIsBrowserAgent(userAgent: string | null | undefined): BrowserAgentDetection;

Detects whether the provided user-agent belongs to a supported AI-agent browser.

isCodexUserAgent(userAgent)

function isCodexUserAgent(userAgent: string | null | undefined): boolean;

Returns true when the user-agent contains the Codex browser token.

useIsBrowserAgent()

function useIsBrowserAgent(): BrowserAgentDetection;

React client hook that reads window.navigator.userAgent after mount and returns the same typed detection shape.

Supported agents

| Agent | User-agent token | | ----- | ---------------- | | Codex | Codex/... |

Example Codex user agent:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Codex/26.429.30905 Chrome/146.0.7680.179 Electron/41.2.0 Safari/537.36

Development

pnpm install
pnpm check
pnpm test
pnpm build