Live Chat

We'll need to share your messages (and your email address if you're logged in) with our live chat provider, Drift. Here's their privacy policy.

If you don't want to do this, you can email us instead at

Sharing variables between Forms

Are you new here?

Anvil is a tool for building full-stack web apps with nothing but Python and a drag-and-drop designer. Learn more on our website, or sign up and try it yourself -- it's free!

Passing values between different Forms is simple. You can create a Module that has global variables, and import it in different Forms. Changing a global variable in one Form makes it available in another.

In this example app there are two different pages, each of which is a different Form. There’s a counter on each Form to display the number of times the user has clicked a link.

This is achieved in a module named Global, which has a variable named number_of_clicks. In each Link’s click handler, number_of_clicks is incremented. The Global module can be imported into each Form, which allows the number_of_clicks to be displayed in a Label.

Click here to clone the example app in the Anvil designer.

Animation of navigation between pages