# Sharing code between Auth0 Rules

**URL:** <https://community.auth0.com/t/sharing-code-between-auth0-rules/50963>\
**Category:** Get Help\
**Tags:** node, rules\
**Created:** [October 5, 2020, 4:49am UTC](https://community.auth0.com/t/sharing-code-between-auth0-rules/50963 "2020-10-05T04:49:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jack.matthews](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jack.matthews/32/12805_2.png) [@jack.matthews](https://community.auth0.com/u/jack.matthews)\
**Post date:** [October 5, 2020, 4:49am UTC](https://community.auth0.com/t/sharing-code-between-auth0-rules/50963/1 "2020-10-05T04:49:23Z")

</div>

We have our Auth0 rules source controlled in GIT. There are a few logging functions that we need to use among multiple different Auth0 rules. Currently they are copied and pasted into every single rule.

I tried es6 imports only to find auth0 does not support them (in fact anything outside of the main function appears to be unsupported).

Has anyone successfully shared code between Auth0 Rules? If so how?

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [October 5, 2020, 7:19am UTC](https://community.auth0.com/t/sharing-code-between-auth0-rules/50963/2 "2020-10-05T07:19:19Z")

</div>

Hey there Jack!

Personally I don’t think it’s doable but it seems like aa nice feature request. Would you mind filing it through our product feedback form? Thank you!

> **[Auth0: Secure access for everyone. But not just anyone.](https://auth0.com/feedback)**
>
> Rapidly integrate authentication and authorization for web, mobile, and legacy applications so you can focus on your core business.

---

<div class="post-metadata">

**Author:** ![john.gateley](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/john.gateley/32/10879_2.png) [@john.gateley](https://community.auth0.com/u/john.gateley)\
**Post date:** [October 5, 2020, 1:20pm UTC](https://community.auth0.com/t/sharing-code-between-auth0-rules/50963/3 "2020-10-05T13:20:10Z")

</div>

Hi @jack.matthews

If the rules are in the same tenant, you can use the global object:

> **[Rules Environment Best Practices](https://auth0.com/docs/customize/rules/rules-best-practices/rules-environment-best-practices)**
>
> Learn about best practices for building Auth0 rules.

John

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [October 20, 2020, 10:42pm UTC](https://community.auth0.com/t/sharing-code-between-auth0-rules/50963/5 "2020-10-20T22:42:20Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
