Ability to prerender dynamic pages via opt-in.
I have a homepage, contact, and about page that pretty much stay the same over time but change with a headless CMS. It seems costly for visitors to have to wait for the API calls each time they're viewing something like a homepage or about page.
Opt-in support of static pages
We're working on a different solution for this. More soon.
So is this like using next export as seen here where you can export dynamic pages into static html and map them to your liking by adding them in next.config.js (code snippet below), but essentially making it work with next build as well?
// next.config.js
module.exports = {
exportPathMap: async function(
defaultPathMap,
{ dev, dir, outDir, distDir, buildId }
) {
return {
'/': { page: '/' },
'/about': { page: '/about' },
'/readme.md': { page: '/readme' },
'/p/hello-nextjs': { page: '/post', query: { title: 'hello-nextjs' } },
'/p/learn-nextjs': { page: '/post', query: { title: 'learn-nextjs' } },
'/p/deploy-nextjs': { page: '/post', query: { title: 'deploy-nextjs' } },
}
},
}
Could we technically run next export and drag the exported html files to the .next/server/static/[build-id]/pages folder (overwriting the .js pages with their .html counterpart) and editing the .next/server/pages-manifest.json to make those routes point to the static html files?
I'm curious about this as i'm planning on supporting a multi language site while keeping SSR using the next-i18next package. so my routes would look like /about-us for english, /fr/about-us for french. I would like to keep static html prerendering when doing a build (for performance), atleast for like the homepage or something.
I'll probably stick to dynamic rendering and wait for the "different solution" listed above, as messing around with build files might not be worth the trouble.
Is there any JS API to render a specific set of pages only instead of exporting the entire site? I have a site with a million pages and we are constantly adding new pages. I want the ability to render only the newly created pages instead of rebuilding the entire website. I didn't find any JS API that I can call based on a webhook whenever any new content is added to a site.
The fallback behavior should have you covered:
https://nextjs.org/docs/basic-features/data-fetching#fallback-true
Additionally: https://github.com/zeit/next.js/discussions/11552