Shinylive Essentials for R Cheatsheet

Quick Guide to Creating and Deploying Shinylive Applications in R

Essential commands, examples, and troubleshooting tips for building and deploying Shinylive R applications entirely in the browser.

Tools
Author
Affiliation
Published

March 22, 2025

Keywords

Shinylive, Shiny R, interactive R, WebAssembly, serverless Shiny

Shinylive Setup & Deployment

Installation

  • From CRAN:
install.packages("shinylive")
  • From GitHub (recommended):
# install.packages("pak")
pak::pak("posit-dev/r-shinylive")

Check installed version:

shinylive::assets_info()

Export & Preview Shinylive App

Export your Shiny app as a Shinylive static webpage:

shinylive::export("myapp", "site")

Preview locally:

httpuv::runStaticServer("site")

In-depth tutorial →



Creating a Basic Shinylive App

Example: Hello Shiny

Create app.R:

library(shiny)

ui <- fluidPage(
  sliderInput("bins", "Number of bins:", 1, 50, 30),
  plotOutput("distPlot")
)

server <- function(input, output) {
  output$distPlot <- renderPlot({
    x <- faithful$waiting
    bins <- seq(min(x), max(x), length.out = input$bins + 1)

    hist(x, breaks = bins, col = "skyblue", border = "white")
  })
}

shinyApp(ui, server)

Export and preview:

shinylive::export(".", "site")
httpuv::runStaticServer("site")

Detailed tutorial →

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)
```

Full guide →

#| '!! 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:

shinylive::assets_info()

Clean old assets:

shinylive::assets_cleanup()

Multiple Apps

Export multiple apps efficiently:

shinylive::export("myapp1", "site", subdir = "app1")
shinylive::export("myapp2", "site", subdir = "app2")

Serve multiple apps:

httpuv::runStaticServer("site")

Advanced tips →

Further Reading


Back to top

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.