huge-iguana
huge-iguana

Reputation: 315

Dynamic components in Next.js static site export

I'd like to use Next.js static site export, but I'd also like to have dynamic components within the templates so that a build wouldn't need to be done every time they change, for example, a 'navigation' component. From what I've read this doesn't seem possible? Are there any workarounds, aside from creating a separate client-side build step?

Upvotes: 0

Views: 1032

Answers (1)

I'm Joe Too
I'm Joe Too

Reputation: 5840

Next is working on allowing for a combined static + SSR generated site, but they're not there yet. I see a few options currently:

  1. You can export a static site, but have that static site make api calls, etc. So you can load your navigation or whatever via api calls. Benefit - no new build. Drawback - those links/that markup is not available to search engines and won't appear initially for users.
  2. If you're using a CMS and CI system (eg, WordPress for content, Travis for CI), you can set up webhooks or functions in WordPress to fire and trigger a rebuild & deploy in Travis when your content changes.
  3. Go full SSR. It still delivers a fully rendered "static" page to the browser, it's just not a static HTML file at build time but one at run time. This is your best option if you need to have your dynamic content rendered immediately for the user and don't want to build with every change.

Upvotes: 1

Related Questions