---
schema_version: "1"
id: f8ba1fcb28f02b537521e21818d007068a56aa82f124a17c83e7dd773e59b36c
title: Lightning Locker
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/lwr-node/lwr/guides/lwr-locker.md
canonical_url: https://developer.salesforce.com/docs/platform/lwr/guide/lwr-locker.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 308a6371229fab4c4c0969b5f2535403bc128fbc047e75b8bb07910883823f80
products:
  - Lightning Web Runtime
---
# 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](https://developer.salesforce.com/docs/platform/lightning-components-security/guide/locker-intro.html).

## 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](https://developer.salesforce.com/docs/platform/lwr/guide/lwr-get-started.md#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"
        }
    ]
}
```
