route-handlers
Skill by davepoon
Route Handlers guides developers through building API endpoints in Next.js with the App Router. It covers route.ts files, HTTP method exports, request and response handling, streaming, CORS and error handling. Use it when adding REST endpoints or streaming responses.
Install route-handlers
Built from the published package, never by AI.
git clone --depth 1 https://github.com/davepoon/buildwithclaude /tmp/buildwithclaude && mkdir -p ~/.claude/skills && cp -r /tmp/buildwithclaude/plugins/nextjs-expert/skills/route-handlers ~/.claude/skills/route-handlersRun in your terminal. Claude Code loads skills from ~/.claude/skills automatically.
git clone --depth 1 https://github.com/davepoon/buildwithclaude /tmp/buildwithclaude && mkdir -p ~/.gemini/antigravity-cli/skills && cp -r /tmp/buildwithclaude/plugins/nextjs-expert/skills/route-handlers ~/.gemini/antigravity-cli/skills/route-handlersAntigravity CLI loads skills from ~/.gemini/antigravity-cli/skills, or .agents/skills for one project.
Skills can run scripts on your machine. Some need an API key: check the README.
About
Route Handlers is an agent skill that gives guidance on building API endpoints in Next.js with the App Router. It explains how to create route.ts files inside the app directory and export functions named after HTTP methods such as GET, POST, PUT, PATCH, DELETE, HEAD and OPTIONS. The skill includes code patterns for reading request bodies, URL and query parameters, headers, cookies and redirects.
It also covers response handling with NextResponse, streaming responses including AI and LLM streaming, CORS configuration, caching with the dynamic option, and error handling with status codes. The skill is aimed at developers building REST APIs or streaming endpoints in a Next.js App Router project. Its examples are snippets, and they call helpers such as a database client that the developer must supply.
Written from the project's SKILL.md and checked against it.
What it can do
- Create route handlersDefine GET, POST and other HTTP method exports in route.ts files under the app directory.
- Read request dataParse JSON, form data and text bodies, plus URL parameters, query strings and headers.
- Build responsesReturn JSON with status codes, custom headers, cookies and redirects.
- Stream responsesSend text event streams and AI or LLM token streams using ReadableStream.
- Configure CORSAdd OPTIONS preflight handling and Access-Control headers to endpoints.
- Control cachingOpt out of caching with the dynamic option or request-dependent APIs like cookies.
- Handle errorsReturn 400 and 500 JSON error responses from try and catch blocks.
What you need
- Next.js project using the App Router
Try asking
- Create a POST route handler that saves a new user in app/api/users
- Add a GET endpoint for /api/posts/[id] that returns 404 when missing
- Stream an LLM chat response from a Next.js route handler
Good to know
- Covers the App Router only, using route.ts files in the app directory
- Example code calls helpers such as db, openai and riskyOperation that the user must provide
Security check
ANo download-and-run commands, hidden instructions or signs of sending keys out were found.
Checked automatically: plugins/nextjs-expert/skills/route-handlers/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work
Inside the skill
-
SKILL.md7 KB -
examples/crud-api.md12 KB -
references/http-methods.md8 KB -
references/streaming-responses.md10 KB
Alternatives to route-handlers
All alternatives →Runs a 7-stage workflow for auditing, cleaning up and reviewing GitHub repositories, plus competitor analysis. Written for developers who want a repo checked for secrets, junk files and documentation gaps.
Teaches an AI assistant to build, debug and explain Gradio web UIs and ML demos in Python. It covers the core API, components, event listeners, layouts and the MCP server option. Aimed at Python developers who work with Gradio.
Recommends menus, buttons, toolbars and disclosure controls for Apple platforms using Human Interface Guidelines conventions. Built for developers and designers making iOS, iPadOS, macOS or visionOS interfaces. Checks existing project design context before asking questions.
Creates production-ready FastAPI project structures with async patterns, dependency injection, and error handling. It is for developers starting new FastAPI applications or backend API projects.
Analyzes Android apps to find user workflows to expose as AppFunctions, so AI agents and system shortcuts can run them without opening the app UI. Generates Kotlin code and refines KDoc for Android developers.
Creates, edits, validates and runs Agent QA tests, suites and hooks through MCP or CLI. It keeps canonical IDs and schema contracts intact, for developers and QA teams using Agent QA.
Compare with openclaw-github-repo-commander, gradio or hig-components-menus
route-handlers: common questions
Does this skill work with the Pages Router?
The source describes guidance for Next.js API development in the App Router, using route.ts files in the app directory. It does not mention the Pages Router.
Which HTTP methods does it cover?
The source lists GET, POST, PUT, PATCH, DELETE, HEAD and OPTIONS as supported methods for route handlers.
How does it handle streaming?
It shows text streaming with ReadableStream and the text/event-stream content type. It also includes an example that streams chunks from an OpenAI chat completion.
How do I install route-handlers?
Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.
Is route-handlers free?
The code is published under the MIT licence. The service it connects to may have its own pricing.
Is route-handlers safe to use?
It scores 87 of 100. Grades: maintenance A, licence A, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.
What are alternatives to route-handlers?
Similar skills: openclaw-github-repo-commander, gradio, hig-components-menus, fastapi-templates.
