You are currently viewing the new Anvil Editor Docs.
Switch to the Classic Editor Docs
You are currently viewing the Classic Editor Docs.
Switch to the new Anvil Editor Docs

Depending On Other Apps

Reusing Components and Code

You can reuse Forms, Custom Components and code from one Anvil app in another by making the app available as a library. Choose “Dependencies” from the Settings Menu Gear Icon.

Making an app available as a library

In the example below, we have made the current app available under the package name “my_app”. This means that Forms, Custom Components and modules from this app can be used by any app that has this app as a dependency.

A dialog where you can select other apps to import into this one, and choose the name this one will have within other apps.

The App Dependencies dialog, found in
the Settings Menu Gear Icon under Dependencies

Using other apps as libraries

In the App Dependencies dialog, you can also import other apps as dependencies.

To use your own apps (or apps you have cloned into your account), click the “My Apps” tab in the dialog and select the app you want to use.

You can also use third-party dependencies by choosing “Third Party” in the App Dependencies dialog and entering a third-party app token. If you would like to enable your app as a third-party dependency, please contact support@anvil.works.

In this example, we’ve imported the Useful Components app (which has the package name useful_components). Any custom components in that app will now show up in the Toolbox in this app:

Custom Components can be found at the bottom of the Toolbox.

You can choose to depend on the Published or Development (most recent) version of the app. Note that if the library app does not have a published version, both options will refer to the most recent version.

You can also refer to library apps in code by importing them as packages. In this way, you can use custom components and modules from libraries directly.

from useful_components.Widget import Widget

self.add_component(Widget())

Any dependencies of an app you depend on will also be available to your app (dependencies are transitive).

It is only possible to depend on apps that you own (or your organisation owns). To use an app that someone else wrote as a library, you should clone their app and then depend on your copy.


Do you still have questions?

Our Community Forum is full of helpful information and Anvil experts.