title: Next.js - How to show post name in the url instead of the id and make it unique?
body: <p>I searched for this but I could only find examples in Laravel and PHP, and I need to know how to do this with Next.js.</p>
  <p>All I know is that I can do dynamic routes in Next.js the usual way like this ...</p>
  <p><code>/pages/post/[postId]</code> which will translate to <code>/pages/post/23435</code> for example, and that way if someone has the URL I could just grab the <code>[postId]</code> with <code>router.query</code> and can show the correct post to the user, easy enough.</p>
  <p>But what if I want to show the post name in the URL instead of the id? just like what Udemy does with dashes between the words ...</p>
  <pre><code>https://www.udemy.com/course/your-custom-react-component/learn/lecture/
  </code></pre>
  <p>And at the same time if someone has that URL I could still show the correct post to them?</p>
  <p>I know I could just do <code>/pages/post/[postName]</code> and show the post name in the URL, but that won't be unique, and won't be able to show the correct post.</p>
  <p>How can I do that?</p>