---
schema_version: "1"
id: e5fa90350ee931128c9b9256a9b8607a51987e333a704112a94a7122f8c52c03
title: Share JavaScript Code Between LWC and Aura
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/lwc/lwc/guides/interop/interop-share-javascript.md
canonical_url: https://developer.salesforce.com/docs/platform/lwc/guide/interop-share-javascript.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: a6114b1bb3b1797d28eb12cd506160ed40a1854b7e092e9e49f691ef73251c6d
products:
  - Lightning Web Components Developer Guide
  - lwc
---
# Share JavaScript Code Between LWC and Aura

To share JavaScript code between Lightning web components and Aura components, put the code in an ES6 module.

To share an ES6 module:

1.  [Create an API module component](https://developer.salesforce.com/docs/platform/lwc/js/js-share-code.md) using the Lightning Web Components programming model.
2.  To use the code in a Lightning web component, [import and reference it](https://developer.salesforce.com/docs/platform/lwc/js/js-share-code.md) in the component’s JavaScript file.
3.  To use the code in an Aura component, use the same syntax that you use to import an Aura component and call its methods. For example code, see the Aura [`lightning:navigationItemAPI`](https://developer.salesforce.com/docs/platform/lightning-component-reference/guide/aura-navigation.html) component docs. Note that `lightning:navigationItemAPI` is an Aura component, not an ES6 module, but to import an ES6 module, you use the same Aura syntax.

**tip:** The [lwc-recipes](https://github.com/trailheadapps/lwc-recipes) repo has an `lmsPublisherWebComponent` module that enables communication between Lightning web components and Aura components.

**See Also**

- [Salesforce Developers Blog: Inter-Component Communication Patterns for Lightning Web Components](https://developer.salesforce.com/blogs/2021/05/inter-component-communication-patterns-for-lightning-web-components.html)
