Shinylive Setup & Deployment
Installation
- From CRAN:
install.packages("shinylive")
- From GitHub (recommended):
# install.packages("pak")
::pak("posit-dev/r-shinylive") pak
Check installed version:
::assets_info() shinylive
Export & Preview Shinylive App
Export your Shiny app as a Shinylive static webpage:
::export("myapp", "site") shinylive
Preview locally:
::runStaticServer("site") httpuv
Creating a Basic Shinylive App
Example: Hello Shiny
Create app.R
:
library(shiny)
<- fluidPage(
ui sliderInput("bins", "Number of bins:", 1, 50, 30),
plotOutput("distPlot")
)
<- function(input, output) {
server $distPlot <- renderPlot({
output<- faithful$waiting
x <- seq(min(x), max(x), length.out = input$bins + 1)
bins
hist(x, breaks = bins, col = "skyblue", border = "white")
})
}
shinyApp(ui, server)
Export and preview:
::export(".", "site")
shinylive::runStaticServer("site") httpuv
Embedding Shinylive in Quarto Documents
Install Quarto extension
quarto add quarto-ext/shinylive
Enable in YAML header:
---
filters:
- shinylive
---
Embed app directly in Quarto
```{shinylive-r}
#| standalone: true
library(shiny)
ui <- fluidPage(
sliderInput("bins", "Number of bins:", 1, 50, 30),
plotOutput("distPlot")
)
server <- function(input, output) {
output$distPlot <- renderPlot({
hist(faithful$waiting, breaks = input$bins)
})
}
shinyApp(ui, server)
```
#| '!! shinylive warning !!': |
#| shinylive does not work in self-contained HTML documents.
#| Please set `embed-resources: false` in your metadata.
#| standalone: true
#| viewerHeight: 650
library(shiny)
ui <- fluidPage(
sliderInput("bins", "Number of bins:", 1, 50, 30),
plotOutput("distPlot")
)
server <- function(input, output) {
output$distPlot <- renderPlot({
hist(faithful$waiting, breaks = input$bins)
})
}
shinyApp(ui, server)
Troubleshooting & Customization Tips
Common Issues
- Missing packages:
- Add hidden package installation:
if (FALSE) {
library(hidden_package)
}
- Slow startup:
- Limit app dependencies for faster loading.
- Assets management:
Check local cache:
::assets_info() shinylive
Clean old assets:
::assets_cleanup() shinylive
Multiple Apps
Export multiple apps efficiently:
::export("myapp1", "site", subdir = "app1")
shinylive::export("myapp2", "site", subdir = "app2") shinylive
Serve multiple apps:
::runStaticServer("site") httpuv
Further Reading
Explore More Articles
Note
Here are more articles from the same category to help you dive deeper into the topic.
No matching items
Reuse
Citation
BibTeX citation:
@online{kassambara2025,
author = {Kassambara, Alboukadel},
title = {Shinylive {Essentials} for {R} {Cheatsheet}},
date = {2025-03-22},
url = {https://www.datanovia.com/learn/interactive/cheatsheets/shinylive-essentials-r.html},
langid = {en}
}
For attribution, please cite this work as:
Kassambara, Alboukadel. 2025. “Shinylive Essentials for R
Cheatsheet.” March 22, 2025. https://www.datanovia.com/learn/interactive/cheatsheets/shinylive-essentials-r.html.