S
S
Smuzzzzi2020-04-27 13:57:17
React
Smuzzzzi, 2020-04-27 13:57:17

How to use dynamic router in Next.js?

Before that, I used the next-routes library and wrote routes like this:

const routes = require('next-routes')
module.exports = routes()
  .add({ name: 'article_detail', pattern: '/:categoty_name/:article_slug', page: 'article_detail' })

The transition was like this:
<Link route={`/${article.category.name}/${article.slug}`}>
  <a>Название статьи</a>
</Link>


Next.js developers now say they support dynamic routes by

default How to use new routes with a transition. That is, if I had a category / link to an article, how can I now specify this in the pages folder?
They offer an option /post/first-post
That is, create a post folder further in it the file [..slug]
How to be in my version?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question