
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
next-middlewares
Advanced tools
This is a library that can use multiple middlewares in Next.
Next's middleware cannot be configured with multiple middlewares. To solve this problem, we provide a library to allow Next to support multiple middlewares.
next-middlewares
is tested with:
13.0.0
and aboveFirst, install next-middlewares
:
$ npm install next-middlewares
# OR
$ yarn add next-middlewares
# OR
$ pnpm install next-middlewares
The way to define middlewares is almost exactly the same as Next. For details, please refer to the Next document Middleware. The difference is that we only support config.match
, other configurations will be ignored.
For example, you can create a new middlewares
folder and create a new redirection middleware redirect.ts
in it, the code is as follows
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'
export function middleware(request: NextRequest): Promise<NextResponse> {
return NextResponse.redirect(new URL('/home', request.url))
}
export const config = {
matcher: '/about',
};
Then, we can create a new middleware.ts
file in the app
or src
or pages
directory of the project according to Next's specifications. And reference our middlewares, use createMiddleware
to combine them. Code show as below:
import { createMiddleware, config } from 'next-middlewares';
import * as RedirectMiddleware from './middlewares/redirect';
import * as RSSMiddleware from './middlewares/rss';
export const middleware = createMiddleware([RedirectMiddleware, RSSMiddleware]);
export { config };
That's all there is to it, your app will support multiple middlewares.
FAQs
A library that can use multiple middleware in Next
The npm package next-middlewares receives a total of 0 weekly downloads. As such, next-middlewares popularity was classified as not popular.
We found that next-middlewares demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.