Quick Start
Install AgentXP and serve your first markdown response in minutes.
1
Install the package
Add
@reaganhsu/agentxp-next to your project.2
Add middleware
Create That’s all you need for a working installation. AgentXP detects AI agents and serves markdown automatically from this point forward.Already have middleware? If you use Clerk, next-intl, or any other middleware, pass it as the second argument:AgentXP runs first. If the request is from an AI agent, it handles the response. Otherwise, it passes the request to your existing middleware unchanged.
middleware.ts in your project root (next to package.json). If your project uses a src/ directory, create src/middleware.ts instead.middleware.ts
middleware.ts
3
Add the AgentExperience component (optional)
Add the The component renders no visible UI. It injects:
AgentExperience component to your root layout to inject structured metadata for agents — a JSON-LD WebSite schema, a link to /llms.txt, and AI-specific robots directives.- JSON-LD structured data (WebSite schema)
- A
<link>to/llms.txt - AI-specific
meta robotsdirectives (noai,noimageai) based on your permissions settings
4
Verify it works
Start your dev server and send a request with You should see clean markdown instead of HTML:Check the response headers to confirm AgentXP is active:You can also verify the auto-generated endpoints:
Accept: text/markdown to any page:Configuration
withAgentXP() accepts an optional configuration object. Here is a full example showing the available options:
AgentXP requires Next.js 14 or later.