I’m building a static site in Next.js. As static sites produce pages with the .html
extension, I’m using the as
attribute on my Link
elements, which allow my pages to be reloaded.
I have now introduced the use of query strings to my URL’s so that, when the pages are reloaded, they remember what content to display, by use of the getInitialProps()
method.
So far, so good, BUT ONLY DURING DEVELOPMENT.
The problem I face is, when the site is exported out as the static version, Next.js fails to call the getInitialProps()
method, hence, when the browser is refreshed, my pages no longer know what to display.
Can anybody help with any of the following:
- Is there another way to allow static pages to be refreshed, without the use of the
.html
extension? - Is there a way to ensure that the
getInitialProps()
method is called when exporting a static site and when reloading a page? - Is there another way in which I can retrieve the query string from the browser URL, as Next.js doesn’t seem to have the ability to access even the top level
window
object?