I have a nextjs app with two pages, they have same design but both display different data, what is the best way to implement this idea with keeping the url path unique for each page.
1 Answer
after asking some friends about this issue the best answer i got (from my prospective) is to separate the repeated code at the two pages into a new directory which I named shared
and a new component that has only one job to display the data passed to it from both pages.
pages/[unique-slug].js
. Depending on the value ofunique-slug
, you may then display relevant data. Docs for your referencepages/[unique-slug]/index.js
so that if you want to introduce a new path underunique-slug/some-path
, it's as simple as creatingpages/[unique-slug]/some-path.js
file.