How to save bookmark state to rds file and restore bookmark state using fileInput with the rds file?

I'm trying to run a shiny app locally on my desktop and I'm looking for a way to download and upload the bookmark state as an rds file instead of copying and pasting a url. I've tried workarounds but they are not as helpful as using shiny's bookmark functions and features. Here is an example app which has the bookmark function. I'm trying to convert this into an app that can download and upload rds file to save and restore the state. Any help will be greatly appreciated.

ui <- function(request) {
      sliderInput("n", "Value to add", min = 0, max = 100, value = 50),
      actionButton("add", "Add"), br(), br(),
      h4("Sum of all previous slider values:", textOutput("sum"))

server <- function(input, output, session) {
  vals <- reactiveValues(sum = 0)
  # Save extra values in state$values when we bookmark
  onBookmark(function(state) {
    state$values$currentSum <- vals$sum
  # Read values from state$values when we restore
  onRestore(function(state) {
    vals$sum <- state$values$currentSum
  # Exclude the add button from bookmarking
  observeEvent(input$add, {
    vals$sum <- vals$sum + input$n
  output$sum <- renderText({

shinyApp(ui, server, enableBookmarking = "url")

This question is also posted here.

For future readers: Here you can find a related answer.

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.