[SalesForce] Can LWC be used with other JS frameworks like ReactJS on VF Pages

Currently the applications are built in ReactJS on top of VF Page.

As part of enhancement, new components need to be built. Also they need to communicate with each other.

I am planning to have LWC going forward, so that I could reuse these for Lightning migration later on.

Can LWC be part of ReactJS app?

Best Answer

I'm pretty sure, you would need to use the Lightning Out feature of the Aura framework. This would render an Aura Component App, which would then in turn render an Aura component wrapper around an LWC.

So essentially, the architecture would be:

VisualforcePage
  |- ReactJS
  |- apex:includeLightning Visualforce tag
     |- AuraComponent App: myLightningApp.app
        |- $A.createComponent on LWC wrapper
           |- LWC: c:myLWCComponent

Given React's strong ownership of the DOM and rendering, honestly, I'm not sure how well all of this would work together. For instance having LWC and the React app interact for instance.

If you think about this, it is the same interoperability structure as using an Aura component, just that you'd use the LWC in place of the Aura component.

My guess is that you'd hoped that there was some way to stand up LWC and have them work directly with React. That's not possible as of today.

Related Topic