Salesforce Sites lets you create public websites and web applications that integrate directly with your Salesforce organization with no requirement for a username or password.
All information stored in your organization can be publicly exposed through your chosen branded URL. You can customize the website pages to match your company’s branded look and feel.
Since sites are hosted on Lightning Platform servers providing Salesforce Lightning Services, no data integration issues arise. The sites are built on native Visualforce pages, so data validation occurs automatically on the collected information.
In this blog, we will provide insights into Lightning Web Components, why we use Salesforce sites now, and how to create a public site in Salesforce with LWC.
What are Lightning Web Components?
The Lightning components use two programming models – Lightning Web Components (LWC) and Aura components.
LWC and Aura components can coexist on the same page and interoperate. They appear as Lightning components to the admins and the end users.
Lightning Web Components uses the core web components standards and provides just what you need for good performance in Salesforce-supported browsers.
However, creating a public site in Salesforce using LWC provides a Lightning-fast fantastic user experience enabling users to interact with the Salesforce organization through public websites.
Why Do We Use Salesforce Sites?
Salesforce organizations comprise information related to partners, solutions, products, users, ideas, and other business data.
Some of this information would benefit people outside your organization, but only users with the proper access and permissions can view and use it.
Typically, you have to set up a web server, create custom web pages (JSP, PHP, or other), and perform API integration between your site and your organization to make this data available to the general public.
To collect information using a web form, you have to program your pages to perform data validation.
There is no need to do any of the above things with Salesforce Sites.
How to Create a Public Site in Salesforce using LWC?
The following are the steps required for creating a public site in Salesforce using LWC:-
Step 1:- Register the Salesforce Sites domain for your organization.
- Go to your Salesforce Org Setup and Search For My Domain in the Quick Find Box.
- Click Edit under My Domain Settings.
Step 2:- Select your Domain name according to your organization’s need and check the availability of your domain name.
- Click the check availability button to check whether your desired domain name is available or not.
- Save the configuration.
Step 3:- In your Salesforce Org Setup, search for Sites in Quick Find Box.
- Select the Checkbox, then click on the Register My Salesforce Site Domain button.
Step 4:- After that, create a new site by clicking on the new button available in the sites settings as shown below:-
Step 5:- Fill in the required fields to provide the necessary information related to your public site
- Select the search icon in front of the Active Site Home Page.
- Select the Visualforce Page that you will use for your site.
- Save the configuration.
Step 6:- LWC Components can be used with Visualforce Pages through the use of the Lightning Application
- Create a VF page (CloudAnalogySite.vfp).
- Create a Lightning Application (CloudAnalogy_App).
- Create an LWC Component (cloudAnalogy).
- The Following Code will provide insight into how to use the LWC Component with VisualForce pages.
VisualForce Page (CloudAnalogySite.vfp)
Lightning Application (CloudAnalogy_App)
Step 7:- You can preview your public site by searching for sites in the Quick Find box in the Salesforce org Setup.
Note: You must provide access to Login IP Ranges | Apex Class | Visualforce Page | External Data Source | Custom Metadata Type | Custom Setting Definitions | Flow | Custom Permissions that your public site will use.
Salesforce organizations contain information like partners, solutions, products, etc., and some information is helpful to people outside the organization.
Earlier, there was a need to set up a web server, create custom web pages, and perform API integration between the site and organization for data availability to the general public. Salesforce sites help you to get rid of all the above-provided steps.
Creating a public site in Salesforce using LWC provides a Lightning-fast user experience enabling users to interact with your Salesforce organization via public websites and building a site with core web components standards as per your business needs.
Cloud Analogy is one of the top-notch certified Salesforce Consulting Companies that can offer you valuable business advice and will assist you throughout your Salesforce journey.
We provide cost-effective Salesforce Consulting Services to help your business grow in countless ways. Reach out to our expert and certified team at Cloud Analogy and start your project today.