Shiny in web browser

Author

Tony Duan

1 option 1: create shiny in quarto doc

1.1 step 1 add quarto extension in project root folder

Code
quarto add quarto-ext/shinylive

1.2 step 2 add in header

---

filters:
  - shinylive
  
---

1.3 step 3 make shiny app

#| '!! shinylive warning !!': |
#|   shinylive does not work in self-contained HTML documents.
#|   Please set `embed-resources: false` in your metadata.
#| standalone: true
#| viewerHeight: 600
#| components: [editor, viewer]
library(shiny)
library(bslib)

ui <- page_fluid(
  h2("Simple Histogram App"),
  layout_sidebar(
    sidebar = sidebar(
      sliderInput("n", "Number of observations:", min = 10, max = 100, value = 30)
    ),
    plotOutput("hist")
  )
)

server <- function(input, output) {
  output$hist <- renderPlot({
    hist(rnorm(input$n), main = "Random Normal Data", col = "skyblue")
  })
}

shinyApp(ui, server)

2 option 2 convert shiny to html

Code
shinylive::export(app_dir="my_shiny_app",output_dir="shiny_web")
https::run_app("shiny_web")
Code
shinylive export my_shiny_app shiny_web
cd site
python -m http.server 8000

3 option 3 upload to shinylive.io

using Shinylive.io

shinylive.io/r/

shinylive.io/py/

Back to top