Search code examples
reactjssalesforce-lightning

LWC and what it provides from a React developer's perspective


I'm a React developer for front-end stuff and I've recently been given the task of evaluating whether or not Lightning Out (LO) or Lightning Web Components (LWC) can be used in our React web app for communicating with Salesforce.

We have some users who will not be able to log directly into our Salesforce instance, and so the suggestion of using LO or LWC has been made as a possible alternative.

As a non-Salesforce developer, I have a question which I don't seem to be able to answer easily:

Do either of these offerings from Salesforce come with any extra functionality other than the look-and-feel? What I mean is, if I add something from LO or LWC to a React app, do they have inherent capabilities for communicating with Salesforce to fetch/update data or are they just "dumb" widgets that look like Salesforce-native widgets?

Are there any advantages to using LO or LWC over any other UI widget library when it comes to working with Salesforce?

Thanks


Solution

  • First of all, feels like you are using LO and LWC interchangeably, so I wanted to clear that up first:

    • LWC: Lighting web components are are custom HTML elements built using HTML and modern JavaScript that use core Web Components standards. I recommend checking out their playground if you want to test them first hand.
    • LO: Allows you to run LWC web components outside of Salesforce servers.

    I am facing some of these questions myself, and I had to do a little bit of digging. I will attempt answer based on what I gathered after some research:

    Do either of these offerings from Salesforce come with any extra functionality other than the look-and-feel?

    The short answer is yes. The true question is whether what's provided is useful in your context or not. For example, they claim that it delivers exceptional performance (although I found solid posts putting that in question), in part thanks to its "Lightning Data Service" (centralized data caching framework which is used to load, save, create and delete a record without any server-side apex code). These are some other things that Salesforce claims are made easier thanks to LWC:

    • Find solutions in common places on the web.
    • Find developers with necessary skills and experience.
    • Use other developers' experiences (even on other platforms).
    • Develop faster.
    • Utilize full encapsulation so components are more versatile.

    Are there any advantages to using LO or LWC over any other UI widget library when it comes to working with Salesforce?

    When it comes to working directly with Salesforce you wouldn't need LO, and yes - there's a very clear advantage to having LWC components as you can easily mount/compose those on any Salesforce page to get desired functionality fairly fast. Particularly beneficial if the System of Record for the data behind the components is Salesforce and you don't currently have a front-end for that data.

    I've seen examples for both using React within Lightning, and LWC (with LO) on a standalone SPA. Now to my 2c: both look atrocious from an app architecture standpoint. In addition to that, it's a pretty clear vendor lock-in, so if you don't have the immediate need or mandate to use LWC, just don't use them.

    If there are any LWC & React experts out there that care to expand and/or correct any of these, by all means...