Where should I load up-to-date data required for ui and server in a golem shiny app?

I have a golem app that loads data from an open government data portal. I need to access the data both in the ui (to make the choices fit the data) and in the server (to make a table and a plot), and I need the data to be up-to-date. Because I want the latest data, I do not load it as raw data and package it with the app. If this were not golem, I would probably load it at the top of the app.R file, thereby making it available both for the ui and the server. I ended up running the data-loading function in the file of the data-loading function, which seems like a bit of a hack. I found other golem apps (e.g. this one) that load the data in the server, where it would be up-to-date but not available to the ui. Where would you recommend to load data - within the golem framework - in a way that it is more or less up to date and available for both the ui and the server?

1 Like


If the data is not static, I would suggest to create all data-dependent UI components on the server side and render them using something like uiOutput().

ok! just to be sure I get what you are saying, so you would load the data in the server? And then update the ui from the server.

Yes. That's what I would do

How would we do it? I'm new to this, could someone help me to see a little more clear?

I'm thinking of something like:
On the ui side:
on the server func:
output$select_input <- renderUI({
selectInput('select', h3('Select Year-Month'),
choices = unique(df$col1))

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.