fridays / next-routes

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

Question: Is it possible to generate routes dynamically from database? #118

Closed kunokdev closed 6 years ago

kunokdev commented 6 years ago

Basically I am building small CMS and I am wondering if it would be possible to generate routes (ones inside routes.js) from database.

fridays commented 6 years ago

Hi @kunokdev I recommend you use a catchall route for this, like so:

routes.add('cmspage', '/:pageslug')

Then in getInitialProps you can use query.pageslug to load the contents from the cms database.

kunokdev commented 6 years ago

Thanks, this will do!