Variables between pages?

Hi,
I have a “main” dashboard and inside that dashboard I do link to other .ps1 files for the other pages.
I have notice that it do work if I declare the variable in the “main” dashboard and that it “travels” to the other pages I guess it’s because that the same runspace/session.

But what’s recommended? Is it recommended to decalare the variabel only on the Dashboard or should I also decaler it on each page?

Example I have it like this inside my main dashboard;

$Pages += New-UDPage -Name 'Radera VDI' -url 'removevdi' -Logo $NavBarLogo -Content {
. "$UDScriptRoot\RemoveVDIPage.ps1"
} -Navigation $Navigation

And in the top of my main dashboard I have a Variable like this $Hi = “It’s a good day”
Should I also deklare it like that in the removevdipage.ps1 or is it just inside the main dashboard?

As I did write I see that it works when I have it just in my main dashboard but I just want to make sure that it’s not going to get in to some trouble long the way.

Product: PowerShell Universal
Version: latest

This configuration is fine. For most cases, we will try to preserve the variable state. A page like this will certainly be fine using a variable defined in the main script. Most of the time when you run into problems with passing variables, it won’t work right away.

That typically will happen when trying to pass automation variables, like $_, to child scopes.