next.js icon indicating copy to clipboard operation
next.js copied to clipboard

mechanism to pass variables to static export html

Open mauvew opened this issue 8 years ago • 1 comments

Thanks a lot for creating this wonderful project

Just wondering is there a way to provide variables or params to the app when using static export. I understand that we can using router to provide query object to the app, but this will result in generating one html for each query value.

But let's say we have a use case that for a web page, we display 10 records at the very beginning, and user can click load more to display another 10 records. After user's refreshing the web page, only 10 records will be displayed. This can be improved by providing a query param called counter=20 in the url. If we have 100 records in total, to achieve this, we can export 100 htmls with counter= 1 to 100 when exporting the static webiste. It looks to me not reasonable to create 100 same htmls, any suggestions on this?

Thanks a lot!

mauvew avatar Jun 25 '18 20:06 mauvew

You can use getInitialProps for the first 10 and then use componentDidMount to fetch more.

timneutkens avatar Dec 31 '18 00:12 timneutkens