NextJS - Production Hot Reloading

Viewed 907

Are there any examples out there of injecting new ReactJS components at Runtime, e.g:

  1. A build is deployed on production is stable and running.
  2. We need to add a component or a new route without running through an entire deploy process.
  3. An additional usecase : the application ships with all the components ( e.g: A CMS Module library) - Only certain components were enabled in layout at build time but need more to be added later via a config.

Approaches I have considered.

  1. Using next getStaticPaths and then using a override in the front-end to inject client side components. This will most probably be seen at runtim
  2. Use a more faster deploy system - This is more obvious but imagine lots of changes within a day and multiple deploys.

Any similar problems or approaches people would have tried would be great.

1 Answers

I think you would lose out on a lot of built-in build optimizations from Next by trying to circumvent the standard build process, e.g. automatic code-splitting as described here.

However, you might find the fallback feature solves your problem entirely - the fallback feature was meant for large ecommerce sites like it sounds like you're working with. As stated at the fallback true docs:

useful if your app has a very large number of static pages that depend on data (think: a very large e-commerce site). You want to pre-render all product pages, but then your builds would take forever.

Related