ShinyURL
:link: Save and restore the state of Shiny app's widgets by encoding them in an URL query string
Install / Use
/learn @aoles/ShinyURLREADME
Installation
# install.packages("devtools")
devtools::install_github("aoles/shinyURL")
Use
-
Load the package in both server.R and ui.R.
library("shinyURL") -
In server.R, add inside the server function a call to
shinyURL.server()where
sessionis the argument passed to the server function. -
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.
-
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) -
Use named lists for the
choicesargument inradioButtonsandcheckboxGroupInput. 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.
Related Skills
node-connect
343.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
92.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
343.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
343.3kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
