Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
next-route-matcher
Advanced tools
Want to use [nextjs-style routes](https://nextjs.org/docs/routing/dynamic-routes) without the [next module](https://github.com/vercel/next.js/)? This module lets you easily match routes. This code was adapted directly from the NextJS implementation.
Want to use nextjs-style routes without the next module? This module lets you easily match routes. This code was adapted directly from the NextJS implementation.
yarn add next-route-matcher
import nextRouteMatcher from "next-route-matcher"
const routeMatcher = nextRouteMatcher([
"/health",
"/api/nested",
"/api/items/[item_name]",
"/api/[someslug]/list",
"/api/[slug1]/deepnest/[slug2]/image.png",
"/api/[someslug]/greetings/[...anything]",
])
routeMatcher("/health")
// {
// matchedRoute: "/health",
// routeParams: {},
// }
routeMatcher("/api/nested")
// {
// matchedRoute: "/api/nested",
// routeParams: {},
// }
routeMatcher("/api/items/someitem")
// {
// matchedRoute: "/api/items/[item_name]",
// routeParams: { item_name: "someitem" },
// }
routeMatcher("/api/someslug/list")
// {
// matchedRoute: "/api/[someslug]/list",
// routeParams: { someslug: "someslug" },
// }
routeMatcher("/api/slug1/deepnest/slug2/image.png")
// {
// matchedRoute: "/api/[slug1]/deepnest/[slug2]/image.png",
// routeParams: {
// slug1: "slug1"
// slug2: "slug2",
// }
// },
routeMatcher("/api/someslug/greetings/something/somethingelse.txt")
// {
// matchedRoute: "/api/[someslug]/greetings/[...anything]"
// routeParams: {
// someslug: "someslug",
// anything: ["something", "somethingelse.txt"],
// },
// }
FAQs
Want to use [nextjs-style routes](https://nextjs.org/docs/routing/dynamic-routes) without the [next module](https://github.com/vercel/next.js/)? This module lets you easily match routes. This code was adapted directly from the NextJS implementation.
We found that next-route-matcher demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.