Shiny bookmarking the state in URL


#1

Hi Tobias & Team,

first of all, thanks again for ShinyProxy – a very happy end user here :slight_smile:

I have a question similar to Pass custom arguments to the Shiny app – but not only on passing data to Shiny via URL params, but also to update the URL of the app as per the bookmarking feature of Shiny: https://shiny.rstudio.com/articles/bookmarking-state.html

It seems that the URL of the app is always static (domain/app/foobar) despite setting in the app:

onBookmarked(function(url) { updateQueryString(url) })

Do you have any suggestions on how to enable bookmarking in apps behind ShinyProxy?

Thanks,
Gergely


#2

Hi @daroczig,

I suspect it isn’t working because ShinyProxy apps run inside an iframe. This imposes some different rules when a script tries to access the browser’s location bar.

That being said, ShinyProxy does support query strings: if you append a query string to the URL, this query string will get forwarded to the shiny app. E.g.

domain/app/foobar?arg=query_string

Regards,
Frederick


#3

Hi Frederick,

Am LOVING shinyproxy!

On the topic of bookmarks though, it seems the query strings are being suppressed by Shiny proxy.

Am am trying with the sample from the shiny site

# Update the browser's location bar every time an input changes. This should
# not be used with enableBookmarking("server"), because that would create a
# new saved state on disk every time the user changes an input.
ui <- function(req) {
  fluidPage(
    textInput("txt", "Text"),
    checkboxInput("chk", "Checkbox")
  )
}
server <- function(input, output, session) {
  observe({
    # Trigger this observer every time an input changes
    reactiveValuesToList(input)
    session$doBookmark()
  })
  onBookmarked(function(url) {
    updateQueryString(url)
  })
}
enableBookmarking("url")
shinyApp(ui, server) 

But I don’t seem to get any query params. Running the app docker container free-standing outside of shinyproxy works fine.

Is there some configuration setting for this please?

thanks!