Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prerender Dynamic Pages #8291

Closed
tylermcrobert opened this issue Aug 8, 2019 · 5 comments
Closed

Prerender Dynamic Pages #8291

tylermcrobert opened this issue Aug 8, 2019 · 5 comments

Comments

@tylermcrobert
Copy link

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

@timneutkens
Copy link
Member

We're working on a different solution for this. More soon.

@andrenaught
Copy link

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.

@nidheeshdas
Copy link

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.

@timneutkens
Copy link
Member

The fallback behavior should have you covered:
https://nextjs.org/docs/basic-features/data-fetching#fallback-true

Additionally: #11552

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants