Next.js: Prerender Dynamic Pages

Created on 9 Aug 2019  路  4Comments  路  Source: vercel/next.js

Feature request

Ability to prerender dynamic pages via opt-in.

Is your feature request related to a problem? Please describe.

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.

Describe the solution you'd like

Opt-in support of static pages

All 4 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

formula349 picture formula349  路  3Comments

sospedra picture sospedra  路  3Comments

knipferrc picture knipferrc  路  3Comments

rauchg picture rauchg  路  3Comments

irrigator picture irrigator  路  3Comments