getting started
Installation
Install next-ai-ready and scaffold your first config.
Prerequisites
- Node.js 20 or later
- Next.js 15+ with App Router (required — route handlers use async
params; Next 14 is not supported) - pnpm, npm, or yarn
- Zod v4 (
zod@^4) — required for actions (usesz.toJSONSchema())
Install
pnpm add next-ai-ready@alpha zod@^4This installs the meta package which re-exports everything you need and provides the CLI.
Package exports (N-14)
| Import | Needs Next.js? | Use for |
|---|---|---|
next-ai-ready | No (CLI + config) | init, build, doctor, defineConfig, defineAction |
next-ai-ready/handlers/* | Yes (server-only) | Route stubs in app/_ai-ready/ |
@next-ai-ready/next | Yes | Monorepo / advanced: same handlers + withAiReady() |
Install one meta package for typical apps: pnpm add next-ai-ready@alpha. The @next-ai-ready/* scoped packages are used internally; you do not need to add them separately.
Optional peers (install only when needed):
| Package | When |
|---|---|
zod@^4 | Actions (required for real projects) |
jiti | ai-ready.config.ts (included as dependency of @next-ai-ready/next) |
mcp-handler, @modelcontextprotocol/sdk | MCP HTTP / stdio |
next | Route handlers only — not required for CLI |
Only `next-ai-ready` exposes the next-ai-ready CLI binary. @next-ai-ready/next also ships a bin for monorepo dogfooding — use the meta package in consumer apps (C-01).
Scaffold (recommended)
npm create next-ai-ready@alpha my-site
cd my-site
pnpm installThe template includes config and handler stubs. Skip to Configure if you already have a project.
Initialize
For an existing Next.js app:
npx next-ai-ready initThis creates:
ai-ready.config.mjs— your site config (includes robots strategy notes)instrumentation.ts+instrumentation-node.ts— optional observability hooks (next-ai-ready/hooks, Edge-safe split)app/_ai-ready/— route handlers forllms.txt,openapi.json, etc.app/api/actions/— the action execution endpointapp/api/mcp/— the MCP server endpointactions/index.mjs— a starter action file with apinghealth check
init also patches next.config with withAiReady() and adds next-ai-ready build to your build script when missing.
Configure
Edit ai-ready.config.mjs to match your site:
import { defineConfig } from "@next-ai-ready/core";
export default defineConfig({
site: {
name: "My Site",
baseUrl: "https://example.com",
description: "A short description for AI.",
},
content: ["app/**/*.mdx", "content/**/*.mdx"],
actions: "./actions/index.mjs",
});Robots policy
next-ai-ready build emits public/robots.txt with explicit AI-bot rules unless you set emit: { robots: false }. For dynamic policies, add app/robots.ts and use aiRobots() from @next-ai-ready/core — Next.js serves app/robots.ts at runtime. Doctor treats that as valid and does not require a static public/robots.txt.
Build
npx next-ai-ready buildThis scans your content, compiles the semantic graph, and writes all AI artifacts to public/ and .next-ai-ready/.
Verify
npx next-ai-ready doctor --scoreDoctor checks your config, validates action exposure rules, detects noai meta, robots strategy, and route wiring. With --score you get a 0–100 readiness score and Top fixes. Use it in CI — exit 0 means no errors (warnings are OK).
For a full walkthrough see the monorepo quickstart-10min guide.