{"library":"nextjs-middleware-chain","title":"nextjs-middleware-chain","description":"A lightweight, zero-dependency Next.js middleware library for chaining middleware functions across API routes and SSR (getServerSideProps) data fetching. Version 0.0.8 (early-stage). Allows reuse of middleware functions by composing them in a chainable API. Differentiators: unified middleware interface for both API and SSR routes, chainable methods, global and per-route options. Release cadence: infrequent, no stable release yet.","language":"javascript","status":"active","last_verified":"Sat Apr 25","install":{"commands":["npm install nextjs-middleware-chain"],"cli":null},"imports":["import { createMiddleware } from 'nextjs-middleware-chain'","import mwFactory from './middleware'","mwFactory().mwFunction().finish(routeFunction, 'Route Name')"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"// middleware.js\nimport { createMiddleware } from 'nextjs-middleware-chain';\n\nconst logger = (req, res, next) => {\n  console.log('Request:', req.method, req.url);\n  return next();\n};\n\nconst mwFactory = createMiddleware([logger], { useChainOrder: true });\nexport default mwFactory;\n\n// pages/api/hello.js\nimport mwFactory from '../../middleware';\n\nconst handler = (req, res) => {\n  res.status(200).json({ message: 'Hello' });\n};\n\nexport default mwFactory().logger().finish(handler, 'Hello API');","lang":"javascript","description":"Shows setup with createMiddleware, then chaining logger and finish in an API route.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}