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

@agentronics/react

v0.1.7

Published

React bindings for the Agentronics SDK.

Readme

@agentronics/react

React adapter for the Agentronics SDK — <AgentronicsProvider>, useAgentronics() and useAgentContext() to authenticate agents operating your pages.

Version: 0.1.6

Next.js

Two pieces: middleware authenticates every request (signed agents, API agents, crawlers), and the provider authenticates agents operating your pages. Start with the middleware.

1. Install

npm install @agentronics/sdk

2. Middleware

// middleware.ts
import { agentronicsMiddleware } from '@agentronics/sdk/next'
import { staticKeyVerifier } from '@agentronics/sdk/server'

export default agentronicsMiddleware({
  apiKey: { verify: staticKeyVerifier(JSON.parse(process.env.AGENT_KEYS ?? '{}')) },
})

export const config = {
  matcher: ['/((?!_next|.*\\..*).*)'],
  runtime: 'nodejs', // needed for crawler reverse-DNS checks
}

Every request continues to your app — verified agents with their identity attached, everything else exactly as before. Agentronics never blocks.

Already using Clerk (or another auth middleware)?

Compose them — run agent auth first, then your user auth:

// middleware.ts
import { clerkMiddleware } from '@clerk/nextjs/server'
import { NextResponse, type NextRequest } from 'next/server'
import { createAgentAuthHandler } from '@agentronics/sdk/server'

const agentAuth = createAgentAuthHandler()

export default clerkMiddleware(async (auth, req: NextRequest) => {
  const out = await agentAuth(req)
  return NextResponse.next({ request: { headers: out.headers } })
})

3. Use the verified agent

In route handlers and server components:

import { headers } from 'next/headers'
import { readAgentHeaders } from '@agentronics/sdk/server'

const agent = readAgentHeaders(await headers())
// { status: 'verified' | 'unverified' | 'none', id, name, vendor, method }

These headers are only trustworthy on routes behind the middleware — it strips any forged x-agentronics-* header before setting them.

4. In-page agents (optional)

To authenticate WebMCP clients and browser agents operating your pages, mount the provider:

npm install @agentronics/react
// app/agentronics-provider.tsx
'use client'
import type { ReactNode } from 'react'
import { AgentronicsProvider } from '@agentronics/react'

export function AgentronicsProviderRoot({ children }: { children: ReactNode }) {
  return (
    <AgentronicsProvider publishableKey={process.env.NEXT_PUBLIC_AGENTRONICS_KEY!} siteId="my-site">
      {children}
    </AgentronicsProvider>
  )
}

Wrap your root layout with it, then use useAgentronics() to reach the client (client.detect(), client.authenticate()). See WebMCP & browser agents.

5. Send auth logs to the console

import { agentronicsMiddleware } from '@agentronics/sdk/next'
import { toTraceEvent } from '@agentronics/sdk/server'

export default agentronicsMiddleware({
  onResult: ({ result, request }) => {
    const event = toTraceEvent(result, { siteId: 'my-site', request })
    if (event) queueForExport(event) // see "Stream auth events to the console"
  },
})

onResult never delays or affects the request. See Stream auth events to the console.

Vite + React

A single-page app only sees agents that run it, so this guide covers in-page agents. Put the server middleware in front of your API as well to authenticate everything else.

1. Install

npm install @agentronics/sdk @agentronics/react

2. Mount the provider

// src/main.tsx
import { createRoot } from 'react-dom/client'
import { AgentronicsProvider } from '@agentronics/react'
import App from './App'

createRoot(document.getElementById('root')!).render(
  <AgentronicsProvider publishableKey={import.meta.env.VITE_AGENTRONICS_KEY} siteId="my-app">
    <App />
  </AgentronicsProvider>
)

Use a publishable key (agtx_pk_…). A secret key throws at start-up.

3. React to the agent

import { useAgentContext } from '@agentronics/react'

export function AgentBanner() {
  const { identity } = useAgentContext()
  if (!identity) return null
  return identity.trust === 'verified' || identity.trust === 'linked'
    ? <p>Signed in as {identity.vendor}</p>
    : <p>An unverified agent is using this page.</p>
}

useAgentContext() re-renders on detect, declare, authenticate and clear.

4. Authenticate a credential

import { useAgentronics } from '@agentronics/react'

const client = useAgentronics()
await client.authenticate({ extensionToken: tokenFromYourAgentExtension })

Credentials are verified through the auth.verifyToken hook — see WebMCP & browser agents.

Bundle impact

The full SDK is ~25 KB (brotli). If you only need WebMCP detection, import from @agentronics/sdk/lite (≤ 8 KB).

Links

License

MIT — © Agentronics.