Skip to content
forked from aoles/shinyURL

🔗 Save and restore the state of Shiny app's widgets by encoding them in an URL query string

Notifications You must be signed in to change notification settings

CIP-RIU/shinyURL

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Installation

# install.packages("devtools")
devtools::install_github("aoles/shinyURL")

Use

  1. Load the package in both server.R and ui.R.

     library("shinyURL")
    
  2. In server.R, add inside the server function a call to

     shinyURL.server()
    

    where session is the argument passed to the server function.

  3. Add the shinyURL widget to ui.R.

     shinyURL.ui()
    

Restoring of tabset and navbar panels

To save and restore active tabs provide the id argument to the functions tabsetPanel or navbarPage.

Disable encoding of certain inputs

You can suppress certain inputs from being encoded in the query URL by using IDs with a leading dot, e.g. .inputName. These inputs won't be restored.

Limitations

Long URLs

The state of a shiny app gets saved by encoding its input values into an URL. To keep the URL compact and to avoid problems caused by the URL length limit (around 2000 characters) there are some points to keep in mind when developing your app.

  1. Avoid long names of inputs but rather use short IDs. For example, instead of

     selectInput("firstDrug", "First drug", choices = drugs)
    

    it's better to have

     selectInput("d1", "First drug", choices = drugs)
    
  2. Use named lists for the choices argument in radioButtons and checkboxGroupInput. Then only the names are displayed to the user allowing for shorter values of the control.

These points are especially relevant for apps with lots of controls.

Action buttons

Unfortunately, operations performed using action buttons cannot be reliably recorded and restored.

About

🔗 Save and restore the state of Shiny app's widgets by encoding them in an URL query string

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • R 99.5%
  • CSS 0.5%