Ooh, I see now. I think typically, bookmarked state is restored by the UI input functions that generate HTML. If you create UI with HTML directly, you'd have to manually restore bookmarked state. Something like this could work (in the server function):
onRestore(function(state) {
updateSliderInput(session, "bins", value = state$input$bins)
})
But easier would be to just create the UI inputs in R, and pass them into the template. Any web dependencies would automatically be included as well. Here's an example I made for the Old Faithful app. I'd also recommend checking out the article on HTML templates: https://shiny.rstudio.com/articles/templates.html.
# app.R
library(shiny)
ui <- function(request) {
htmlTemplate("www/index.html",
binsInput = sliderInput("bins", "Number of bins:", min = 1, max = 50, value = 30),
bookmarkBtn = bookmarkButton(),
distPlot = plotOutput("distPlot")
)
}
server <- function(input, output, session) {
output$distPlot <- renderPlot({
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
}
shinyApp(ui = ui, server = server, enableBookmarking = "url")
<!DOCTYPE html>
<!-- www/index.html -->
<html>
<head>
{{ headContent() }}
{{ bootstrapLib() }}
</head>
<body>
<div class="container-fluid">
<h2>Old Faithful Geyser Data</h2>
<div class="row">
<div class="col-sm-4">
<div class="well">
{{ binsInput }}
{{ bookmarkBtn }}
</div>
</div>
<div class="col-sm-8">
{{ distPlot }}
</div>
</div>
</body>
</html>