How to transfer some data with dcc.store from port A to port B

Hi guys !!

I am using multi pages dash app.
The pages have own different port number such as
Page1 = 8050, Page2 = 8051 …

i get the input data from page1 and store into dcc.Store, however I can not transfer it to other pages with other port number.

How to transfer some data with dcc.store from port A to port B???

HI @Y.J out of curiosity, how did you set this up? Is every page a separate dash app in some kind of a framework?

Hi, surely this would have something to do with CORS,however it is setup

Reg,
J.

First, i made 4 pages and redirect by dcc.link with different ports.

Second, I success store the data with dcc.Store in the first page (infact, i got an user id and stored)
But I can not get it in the second page. ( i don’t know how to do this!!!)

Help me!!!

Hello @Y.J,

Each store is only available on its domain, as these are two different ports, these are two different domains.

If, however, you were to use a reverse proxy and put them onto the same domain, then you could make it work.

Or, you could host the on the same port with different base urls.

thanks for your reply!!
The reason I used multiple ports to create pages is that I didn’t want to use dash.page_container. You see, when using dash.page_container, it only displays different pages within the designated area of the first page (the route page), and I didn’t want that. I wanted each page to utilize the entire screen space.

Anyway, I understood that there might be a possible way to achieve this even when using multiple ports, but it might not be easy, right?

um… is the only way I can is to merge one port ?

You can setup a page container to take up the entire screen, there’s nothing saying that you can’t.

Just do:

app.layout = dash.page_container

You can’t share stores across domains, that’s a browser thing.

If the above doesn’t work for you, then I recommend running both apps on the same port with different base urls.

1 Like

thanks a lot !!
maybe from your advice, I just add one page and then it will work with one port :slight_smile:
I will try this !!!

You’d have to make two different pages. But yes, hopefully it will work.

1 Like

Thanks !!! I am done !! (in my local staging demo)

I will apply this to my system. :slight_smile:

1 Like

as I mentioned before,

I used multi ports in my dash app(I mean pages have own their port number),
then now I made this one port!!! in order to share dcc.store value(data).

however when I want to get the dcc.store data from page1 to another page.
on anoother page, I can not use dcc.store as input…

I got this error. please !! help me !!!

this is the part of my page1

and this is the part of another page.

Dcc.stores that are going to be shared do not exist until the page is navigated to.

It would be better to add these stores to the app layout and then pass data to it as needed from a callback as necessary. Especially when you navigate to a page.

Just have a callback that triggers from the id of a component on the page and update the data in the store from it.

thanks !
however I did as you said first,
and I tried to apply when the navi open, get the dcc.value… this is one of exam…

my problem is I can not use dcc.Store on the another page.
you can understand my error… nonexistent object in an ‘Input’ == it means my dcc.Store component…

what is that I missed ? how should I solve this ??? ㅠㅠ

ps.
…extra explanation…
I am so serious … I do want to solve this… help me… I am also searching the solution…

I’ve had some problem which i can not get the dcc.Store value(data) with multi page.

the user flow is like this, app.py → login.py → main.py

and I want to transfer the ID info from login.py to main.py.

please help me !!! you can save me !!

in my case, I got this error

this is your code.

@callback(Output(“dropdown-container”, “children”), Input(“stored-data”, “data”))
def populate_dropdownvalues(data):
dff = pd.DataFrame(data)
return dcc.Dropdown(
id=“dropdown”,
options=[{“label”: x, “value”: x} for x in dff.day.unique()],
value=dff.day.unique()[0],
clearable=False,
style={“width”: “50%”},
persistence=True,
persistence_type=“session”
),

this is my app.py

and this is the part of my main.py in order to get the dcc.Store data

Could you share this setup? Maybe a MRE?

Your dcc.Store needs to be in your app.py layout.

1 Like