Dynamic route regex pattern
Answered
Highlander posted this in #help-forum
HighlanderOP
I want to implement dynamic route with specific regex pattern like /blog/[1-9+]/page.jsx
Answered by Ray
currently, not a build-in feature but you could try something like this
// blog/[id]/page.tsx
export default function Page({params}) {
const id = /[1-9+]/g.test(decodeURIComponent(params.id))
if (!id) notFound()
}1 Reply
@Highlander I want to implement dynamic route with specific regex pattern like /blog/[1-9+]/page.jsx
currently, not a build-in feature but you could try something like this
// blog/[id]/page.tsx
export default function Page({params}) {
const id = /[1-9+]/g.test(decodeURIComponent(params.id))
if (!id) notFound()
}Answer