/nemo:nemo-setupfrom NEMO for Next.js
Sets up @zanreal/nemo in a Next.js app to compose multiple middlewares into a single proxy.ts or middleware.ts file. Handles installation, file creation, matcher config, and route definition.
Ships in NEMO for Next.js. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
NEMO (@zanreal/nemo) composes many Next.js middlewares into one proxy.ts / middleware.ts. You describe routes as an object, NEMO runs the matching functions in a defined order and stops the chain when one returns a redirect, rewrite or other final response.
Read next in package.json.
| Next.js | File | Export name |
|---|---|---|
| 16 or newer | proxy.ts | export const proxy |
| 15 or older | middleware.ts | export const middleware |
Put the file next to app/ (or inside src/ when the project uses src/). If the project already has one of these files, do not overwrite it: read it and follow the nemo-migrate skill.
Use the project's package manager (check the lockfile):
npm install @zanreal/nemo
pnpm add @zanreal/nemo
yarn add @zanreal/nemo
bun add @zanreal/nemo
Peer dependency is next >=13. The package ships ESM only (its require condition points at the same ESM build). Next.js handles that; in Jest see nemo-debugging/references/testing.md.
Next.js 16+ (proxy.ts):
import { createNEMO, type MiddlewareConfig } from "@zanreal/nemo";
import { NextResponse } from "next/server";
const middlewares = {
"/dashboard/:path*": async (request, event) => {
request.headers.set("x-section", "dashboard");
return NextResponse.next();
},
} satisfies MiddlewareConfig;
export const proxy = createNEMO(middlewares);
export const config = {
matcher: ["/((?!_next/|_static|_vercel|[\\w-]+\\.\\w+).*)"],
};
Older Next.js (middleware.ts): same code, but export const middleware = createNEMO(middlewares);.
Rules that matter:
createNEMO(middlewares, globalMiddleware?, config?) returns the handler directly. Do not write new NEMO(...) unless you also use .middleware (export const proxy = new NEMO({...}).middleware).createMiddleware. It is deprecated and prints a console warning.NextResponse and NextRequest from next/server. StorageAdapter and MemoryStorageAdapter come from @zanreal/nemo/storage, not from the main entry.config.matcher must be a static literal in the same file (a Next.js rule). Next.js only calls the file for paths the matcher accepts, NEMO routes are applied after that.The first argument maps path patterns to a function, an array of functions, or a nested object.
import { createNEMO } from "@zanreal/nemo";
import { NextResponse } from "next/server";
export const proxy = createNEMO(
{
// exact path only: runs for "/pricing", not for "/pricing/anything"
"/pricing": (request) => {
request.headers.set("x-page", "pricing");
},
// prefix with parameters: runs for "/blog", "/blog/a", "/blog/a/b"
"/blog/:path*": [
(request) => {
request.headers.set("x-section", "blog");
},
(request) => {
request.headers.set("x-blog", "1");
},
],
// nested: parent runs for the whole subtree, children add on top
// (nested children match as prefixes too: "/settings" also runs for /app/settings/x)
"/app": {
middleware: (request) => {
request.headers.set("x-app", "1");
},
"/settings": (request) => {
request.headers.set("x-settings", "1");
},
},
},
{
// global chains run on every request that reaches NEMO
before: (request) => {
request.headers.set("x-request-start", String(Date.now()));
},
after: () => NextResponse.next(),
},
{ debug: false, silent: false },
);
Key facts:
"/foo" does NOT run for /foo/bar. Use "/foo/:path*" or a nested object for prefix matching."/app": { "/settings": fn } runs fn for /app/settings and /app/settings/x)."/" runs only for the exact root path /. It is not a catch-all. For "every request" use globalMiddleware.before.:param, :param*, :param+, :param?, (regex)). Patterns with :, * or ( match case insensitively; plain paths like "/pricing" are compared exactly, case included. An invalid pattern is logged with console.error and never matches, nothing is thrown.before, then matched routes (parents before children; at the same depth, longer patterns first), then global after.undefined or NextResponse.next() lets the chain continue. NextResponse.redirect, NextResponse.rewrite, NextResponse.json or a plain new Response(...) end it. See the nemo-middleware-patterns skill for all rules.next dev and request a matched and an unmatched path. Set debug: true in the third argument for NEMO's internal logs (event.log prints with debug: true in the first release after 3.0.2; on 3.0.2 and older it prints nothing, use event.warn).satisfies MiddlewareConfig gives contextual types to request and event.nemo-debugging skill.proxy vs middleware).export const config = { matcher: [...] } present and excludes _next, static files and assets.createMiddleware, no req.params (use event.params), no new NEMO without .middleware./:path* or nesting, not a bare path.new URL("/login", request.url).new Response(...) or NextResponse.json(...), not new NextResponse(body, { status }).What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub zanreal-labs/nemo --plugin nemo4 skills in this plugin
/nemo-debuggingDebug and test @zanreal/nemo middleware - a middleware not running, a response ignored, a 401 or redirect lost, headers or cookies missing, storage leaking between requests, NemoMiddlewareError, event.log printing nothing, and unit tests with NextRequest. Use when NEMO behavior is unexpected or when writing tests for a createNEMO config./nemo-middleware-patternsWrite and organize @zanreal/nemo middleware - chains, nested and parameterized routes, global before/after, shared storage, redirects, rewrites, header and cookie forwarding, auth gating, i18n, event.skip. Use when adding or changing logic inside a createNEMO config, choosing how to stop or continue a chain, or working out why a NEMO middleware does or does not run./nemo-Other plugins' skills for the same job