NextJS Router Matcher
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.
Installation
yarn add next-route-matcher
Usage
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")
routeMatcher("/api/nested")
routeMatcher("/api/items/someitem")
routeMatcher("/api/someslug/list")
routeMatcher("/api/slug1/deepnest/slug2/image.png")
routeMatcher("/api/someslug/greetings/something/somethingelse.txt")