11.3 Modifying App

There are three main parts you must modify in a Shiny app in order for it to be bookmarkable:

In ui: make it a function Why? Because Shiny needs to be able to modify the input controls specified by the URL. Like arguments are passed within a normal R function as parameters to produce different outputs, the ui now needs to take in an argument (the URL) in order to return the app into a particular state. The URL holds information on the input parameters that needs to be changed, hence why the ui now needs to be a function.
In ui: add the bookmarkButton() function This function adds a button to the ui that captures the current values of all the input controls and generates a URL from it. More on this later.
In shinyApp() call: include enableBookmarking = "url" This function ultimately puts the app together - the ui and the server. Adding this argument tells Shiny enable bookmarking and that the bookmark will be URL-encoded vs saved-on-server. More on this later
ui <- function(request) { # make it a function
  fluidPage(
    sidebarLayout(
      sidebarPanel(
        sliderInput("omega", "omega", value = 1, min = -2, max = 2, step = 0.01),
        sliderInput("delta", "delta", value = 1, min = 0, max = 2, step = 0.01),
        sliderInput("damping", "damping", value = 1, min = 0.9, max = 1, step = 0.001),
        numericInput("length", "length", value = 100),
        bookmarkButton() # add an interactive button
      ),
      mainPanel(plotOutput("fig"))))}

# enable bookmarking!
shinyApp(ui, server, enableBookmarking = "url")