3

I need to use my lightning component in a web page which is not in any way related to salesforce(its not a SF community or site, its an existing web page that is live). This web page uses a form, and we need to replace this existing form with our lightning component. The data entered in this form should come in to salesforce custom object.

After some research on lightning out, what I could gather was that it requires a connected app and asks for login before this component can be used, which is not desirable in our case. This blog explains the use of lightning out in a node app while this video explains its use in sharepoint/heroku.

  1. Similar to these examples, how can we expose lightning component in an existing web page, with the authentication happening in backend or without user having to do that extra click?
  2. If I need to develop such a system I need to create a sample website(HTMl page) for testing and add ltng out code to this web page. How can I test this web page as I do not have a domain to host it? Can it be hosted on "localhost"?

Some questions here may be very basic. Please correct my understanding if I am missing anything. Thanks in advance!

3

How can we expose lightning component in an existing web page, with the authentication happening in backend or without user having to do that extra click

You have to import lightning.out JS from your mydomain and then use$Lightning.use() function which takes authToken (SessionId , OAuth access).

Now in your server back you can use any SF's username /password flow or JWT flow to generate the access token, and pass it to the front end, which lightning,js can use.

If I need to develop such a system I need to create a sample website(HTMl page) for testing and add ltng out code to this web page. How can I test this web page as I do not have a domain to host it? Can it be hosted on "localhost"?

From the requirement list:

A) Ability to modify the markup served to the client browser, including both HTML and JavaScript. You need to be able to add the Lightning Out markup.

B)Ability to acquire a valid Salesforce session ID. This will most likely require you to configure a Connected App for the origin server.

C) Ability to access your Salesforce instance. For example, if the origin server is behind a firewall, it needs permission to access the Internet, at least to reach Salesforce.

If your localhost can satify these requirements, I believe you should be able to host on localhost.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.