2

A colleague was giving a very exciting presentation on Micro Frontends today. He explained that if you can import the web-components into your JavaScript, you could compose your UI using components from any number of sources.

As we know by now, Lightning Web Components really are mostly using standard web technologies and you don't even need Salesforce to host a solution built with it.

Well, if LWC are really standard web components, then in follows I should be able to consume them on a website which is hosted elsewhere.

But then the question becomes, whether and how it is actually possible to expose the webcomponent which is hosted in Salesforce, which may be wired into AuraEnabled classes? Can it be done securely?

If it is not possible now, is this on the roadmap?

4
  • 1
    It's called Lightning Out
    – identigral
    Jul 15, 2020 at 17:25
  • @identigral If that works with LWC (I only see Aura) and if it were an answer, I would accept this. :-) Jul 16, 2020 at 13:31
  • 1
    In Lightning Out deployment / delivery model, Aura enabled app is a lightweight container for LWCs
    – identigral
    Jul 16, 2020 at 17:05
  • @identigral, if I understand correctly, it's not that the Aura enabled app is specifically a container for the LWCs, but it should work because Aura components should be able to host LWCs and an aura app is basically just an aura component that doesn't need to be embedded in a Lightning App page? Would an LWC be able to have two-way communication with the rest of the page it is embedded in? How would that work? Jul 17, 2020 at 8:56

1 Answer 1

3

It is not possible the way you're describing it (IE accessing the LWC "Hosted on Salesforce", accessing Apex methods directly via @AuraEnabled annotation)

You could expose a Salesforce Community site on the public internet but the only elements would be Embedded Services with CORS-enabled (this is what comes to mind- there may be others, I was just working on this yesterday with the FSL Scheduler and "embedding it" in a 3rd-party "Site", or Chat/Chat-bots, though most documentation targets placing them in different types of Salesforce Communities, and doesn't adequately demonstrate using them on 3rd party sites IMOP)

Your correct LWC is based on web-standards (IE Web Components) but this is just for client-side (read: browser) of a JavaScript/HTML/CSS, the "hosting" aspect still needs to happen in some sort of HTTP web-server to return said-components to the browser.

6
  • 3
    +1 I would say it's theoretically possible, but it would be very Frankenstein Monster-ish to get it to work. It'd probably be easier to just say, "no, no, don't do that" and be done with it.
    – sfdcfox
    Jul 15, 2020 at 17:06
  • 1
    Some of the configuration hoops you have to jump through to make Communities work in this way are Frankenstein Monster-ish 😉 Jul 15, 2020 at 17:10
  • Just out of curiousity, what would either of these monsters look like? Jul 15, 2020 at 17:11
  • 1
    @BrianKessler first thought: 1. Create a Community Page that is publically accessible, IE users are assigned a "Guest"/"anonymous" license when accessing this page. Note: the restrictions around "guest" access to Communities based pages is extremely opaque IMOP. (2) Embed LWC component in that page (again not sure if it's even possible to grant 'guest' or 'anonymous' access to the APEX Api method (doubting this). (3) iFrame said page into another page. Jul 15, 2020 at 17:23
  • 1
    @BrianKessler - this is "Salesforce development" (I always think the same thing every time I come back to the platform) but they're a STAPLE in Salesforce especially in Enterprise software with SSO and all kinds of ancient browser ramifications Jul 16, 2020 at 15:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .