Lightning Locker
To improve the security of your LWR apps, enable Lightning Locker.
Locker is a security architecture for Lightning web components (LWCs). To learn how Locker enhances the security of your components and code, visit Lightning Aura Components Developer Guide: Lightning Locker.
Compatibility with LWR
- Locker is only supported for applications in AMD mode. It doesn’t work for ESM mode. For more information about LWR application modes, see Set the LWR Server Modes.
- Locker is only supported on the client-side. You can’t enable Locker for server-side code.
Enable Locker
To opt-in to Locker, add the locker config to your project’s lwr.config.json. You can determine which components run outside of Locker by listing them in the trustedComponents property.
1{
2 "lwc": {
3 "modules": [{ "dir": "$rootDir/src/modules" }]
4 },
5 "locker": {
6 "enabled": true,
7 "trustedComponents": ["lightning/*", "example/app", "example/trustedCmp"]
8 },
9 "routes": [
10 {
11 "id": "locker-base",
12 "path": "/",
13 "rootComponent": "example/app",
14 "layoutTemplate": "$layoutsDir/main.html"
15 }
16 ]
17}Developer Preview Feature