Data Prefetch

Deprecated

Legacy Data Prefetch has been removed. The .prefetch.ts, dataPrefetch, and @module-federation/enhanced/prefetch APIs are no longer available.

Use bridge-react - prefetch instead. It supports Rspack/Webpack and works in both SSR and CSR scenarios.

How to migrate to bridge-react - prefetch

Producer

  1. Rename the .prefetch.ts file to .data.ts.
  2. Change the default export to a named export called fetchData.
  3. Remove dataPrefetch from your config file.
  4. If you are using the defer API, remove it.
  5. If the component uses usePrefetch to fetch data, accept the data via props instead.

The producer does not execute fetchData by itself. It is only called when the consumer loads the module, and the result is injected into the component.

If the producer application also needs to render this component with data, call fetchData before rendering and pass the data via props.

Consumer

  1. Remove dataPrefetch from your config file.
  2. Use createLazyComponent to load the producer. See bridge-react - data fetch.
  3. Use prefetch to prefetch data.