Description
Feature request
Is your feature request related to a problem? Please describe.
We want some static pages to be as lightweight as possible and we're fine with full page reloads navigating out of them if we can chop off extra 200Kb.
Describe the solution you'd like
Add an option to path map in next.config.js to indicate this specific page doesn't need to include react app and can operate as plain HTML page.
React app is only removed in case the flag is set to true
explicitly.
Looks like it should be enough to just make files
content empty there if option is set. https://github.com/zeit/next.js/blob/canary/server/render.js#L100
For the simple example from tutorial setting up
// next.config.js
module.exports = {
exportPathMap: function(defaultPathMap) {
return {
'/': { page: '/', withoutReact: true },
'/about': { page: '/about' }
}
}
}
As a result /out
would be populated with
<!--/out/index/index.html-->
<!DOCTYPE html>
<html>
<head>
<meta charSet="utf-8" class="next-head"/>
</head>
<body>
<a href="/about">About</a>
</body>
</html>
<!--/out/about/index.html-->
<!DOCTYPE html>
<html>
<head>
<meta charSet="utf-8" class="next-head"/>
<link rel="preload" href="/_next/9d298d49-6fb5-4c6f-a992-31fdb0d3e01a/page/about.js" as="script"/>
<!--other scripts-->
</head>
<body>
<!--page content -->
<script>
NEXT_DATA = {"props": "etc.."}
</script>
<script id="__NEXT_PAGE__/about" src="..."></script>
</body>
</html>
This way index page is going to be very lightweight, with a tradeoff of full page reload navigating to /about. While /about would load the app, so navigation back to / would be handled on the client-side.
Describe alternatives you've considered
Static site generators :) But we need way more than just static pages and next.js fits us best except for this tiny quirk.
Additional context
Happy to implement that, just wanted to make sure this is not something going against the roadmap for next.js. Or if it's something already available, but hidden. I'm new to the library, only playing around for the second day.