fridays / next-routes

Universal dynamic routes for Next.js
MIT License
2.47k stars 230 forks source link

Add route resolution by URL #58

Closed fridays closed 7 years ago

fridays commented 7 years ago

Adds the possibility to resolve routes by URL in addition to name.

routes.add('blog', '/blog/:slug')
<Link route='/blog/hello-world'><a>Click</a></Link>
Router.pushRoute('/blog/hello-world')
Router.replaceRoute('/blog/hello-world')
Router.prefetchRoute('/blog/hello-world')

The interface didn't change. If no route was found by name, it tries to find one by matching it against the patterns. If still no route was found, it passes it on to next as it came in.

Closes #46 closes #23 closes #21