Pass arguments to layout() in multi page apps

Hi, before the last update I used to create my multi-page apps in a hacky way:

  • I would define a generate_layout() and a generate_callbacks() method for every page
  • During the app initialization I would load the modules callbacks
  • I would then get the active page from an input and based on that load the layout.

Now I am trying to migrate my code to take advantage of the new multi page implementation, however there is something that I can’t get my head around on how to replicate. Before I could initialize different global variables in my main module that could be shared across pages just by passing them as arguments when calling the layout and callbacks load methods. This allowed me to share any dynamic object such as a database client or an OPC server client that could be used within the layout or callbacks of every module.

Is there any way of passing arguments to the layout function with the new implementation, maybe in the register_page function having an argument that sets the required variables to pass when calling the layout method?


Hi @JuanMiguel

For string variables, you can pass them as path variables in the URL You can find more info here:

Other global variables could be defined in a utility file then imported in files in the pages folder.

You might find this repo of mullti-page examples helpful: