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.

{
    "lwc": {
        "modules": [{ "dir": "$rootDir/src/modules" }]
    },
    "locker": {
        "enabled": true,
        "trustedComponents": ["lightning/*", "example/app", "example/trustedCmp"]
    },
    "routes": [
        {
            "id": "locker-base",
            "path": "/",
            "rootComponent": "example/app",
            "layoutTemplate": "$layoutsDir/main.html"
        }
    ]
}