Salesforce has just announced a new Beta feature in the Winter ’22 release notes: Lightning Web Security. What is this exactly?
Lightning Web Security (LWS) is a new client-side security architecture for Lightning Web Components (LWC) that replaces Lightning Locker. LWS is defined by fewer restrictions while preserving the same strong security capabilities of Lightning Locker, such as blocking or modifying behavior of APIs that aren’t secure.
How is it implemented?
What can I do with LWS that I couldn’t with Lightning Locker?
With LWS you can:
- Import and use LWCs from different namespaces via composition or extension.
- Interact with global objects.
- Use 3rd party libraries that manipulate global objects.
LWS also provides improved performance compared to Lightning Locker because it doesn’t use secure wrappers which can reduce performance.
How can I activate it?
You can activate LWS for your custom LWCs in a Spring ’22. This will affect all your custom components, including those in managed packages. Go to Setup → Session Settings and enable “Use Lightning Web Security for Lightning web components”.
Note that LWS is GA in Spring '22 only for LWC. Activating it in a mixed mode org (Aura + LWC) is not yet supported and issues may arise.
How can I report issues?
To report issues, give feedback, and ask questions about LWS, go to this link.
Where can I learn more?
Take a look at these resources: