I created a nextJS application and using its routing system there. Now I have created a dynamic route to catch a URL like {base_url}/{username}/{post-slug}. But it is also capturing {base_url}/post/create which I want to be rendered on different page.
So is there anything available in nextJS route to match a URL absolutely? Like, exact in react router? Or do I have to redirect user from getInitialProps function in nextJS?
1 Answer
I created sample codesandbox for this question.
It works without Regular Expression. Always the specific route (post/create) has the priority.
I hope this helps you.
1 Comment
tatsuya kanemoto
Oh... I'm sorry I misunderstood your question. This is not a direct anwer but, I think the structure of your user route should be
{base_url}/user/{username}/{post-slug}. This matches http://yourhostname/user/{username}/{post-slug} and doesn't conflict the post route.
Regular expressionmay help