Shiny Web Apps

Author

Thomas Girke

Published

May 30, 2026

Download qmd

What is Shiny?

Shiny is an R-based environment for building interactive web applications for data analysis and exploration (Shiny - Tutorial,” n.d.; Chang et al. 2023). Since most JavaScript code is autogenerated by the environment, basic R knowledge is sufficient for developing Shiny apps. They can be deployed on local computers or web servers including custom and cloud-based servers (e.g. AWS, GCP, shinyapps.io service). Since 2023, Shiny is also available for Python — see Shiny for Python — though this tutorial focuses on the R version. The basic structure of a Shiny app is an app.R script containing the following components:

Step 1. User interface

ui <- fluidPage()

Step 2. Server function

server <- function(input, output) {}

Step 3. Statement to run shiny app

shinyApp(ui = ui, server = server)

Alternatively, the ui and server functions can be organized in two script files, a ui.R and a server.R script, respectively.

Develop and test Shiny app locally

Open R and set session to parent directory (here myappdir) containing shiny script app.R, and the run it with the runApp() function. A sample app.R script for testing can be downloaded from here.

library(shiny)
dir.create("myappdir")
download.file("https://raw.githubusercontent.com/tgirke/GEN242/refs/heads/main/tutorials/shinyapps/scripts/app.R", "./myappdir/app.R")
runApp("myappdir") # To show code in app, add argument: display.mode="showcase" 

This will open the app in a web browser.

Deploy on web server

This can be done on local or cloud systems. An easy solution is to get an account on shinyapps.io and then deploy Shiny apps there. For details, see here.

setwd("myappdir")
library(rsconnect)
deployApp()

Example Shiny app

The following Shiny app is hosted on shinyapps.io (here Instructor account) and embedded into the markdown (or html) source of this page using the following iframe syntax:

<iframe src="https://tgirke.shinyapps.io/diamonds/" style="border: none; width: 880px; height: 900px"></iframe>

Another example from Nick Harding using Shiny App: volcanoshiny

Additional examples

Resources to Learn Shiny

Built-in examples

The shiny package ships with example apps that are a good starting point. To explore them:

mydir <- system.file("examples", package="shiny")
dir.create('my_shiny_test_dir')
file.copy(mydir, "my_shiny_test_dir", recursive=TRUE)
setwd("my_shiny_test_dir/examples")
runApp("01_hello") # Runs first example app in directory 
dir() # Lists available Shiny examples (directories). 

Individual examples can also be loaded directly — see Lesson 1 on the Posit Shiny site.

Tutorials and books

Extension packages and tools

  • Catalog of extension packages — Awesome Shiny
  • shinyWidgets — UI components
  • systemPipeShiny — A framework for workflow management and data visualization
  • spsComps — UI components, animations, server components
  • shinyjs — server-end JavaScript communications
  • shinylive — Run Shiny apps entirely in the browser via WebAssembly (no server required); also embeddable directly in Quarto documents via {shinylive-r} chunks

Session Info

sessionInfo()
R version 4.5.1 (2025-06-13)
Platform: x86_64-pc-linux-gnu
Running under: Debian GNU/Linux 11 (bullseye)

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0  LAPACK version 3.9.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: America/Los_Angeles
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] fgsea_1.36.0  ggplot2_4.0.1

loaded via a namespace (and not attached):
 [1] Matrix_1.7-4        gtable_0.3.6        jsonlite_2.0.0      dplyr_1.1.4         compiler_4.5.1      tidyselect_1.2.1    Rcpp_1.1.0          parallel_4.5.1      dichromat_2.0-0.1   scales_1.4.0       
[11] BiocParallel_1.44.0 yaml_2.3.12         fastmap_1.2.0       lattice_0.22-7      R6_2.6.1            generics_0.1.4      knitr_1.51          htmlwidgets_1.6.4   tibble_3.3.0        pillar_1.11.1      
[21] RColorBrewer_1.1-3  rlang_1.1.6         fastmatch_1.1-6     xfun_0.55           S7_0.2.1            otel_0.2.0          cli_3.6.5           withr_3.0.2         magrittr_2.0.4      digest_0.6.39      
[31] grid_4.5.1          cowplot_1.2.0       lifecycle_1.0.4     vctrs_0.6.5         data.table_1.18.0   evaluate_1.0.5      glue_1.8.0          farver_2.1.2        codetools_0.2-20    rmarkdown_2.30     
[41] tools_4.5.1         pkgconfig_2.0.3     htmltools_0.5.9    
Back to top

References

Chang, Winston, Joe Cheng, JJ Allaire, Carson Sievert, Barret Schloerke, Yihui Xie, Jeff Allen, Jonathan McPherson, Alan Dipert, and Barbara Borges. 2023. Shiny: Web Application Framework for r. https://shiny.rstudio.com/.
Shiny - Tutorial.” n.d. https://shiny.rstudio.com/tutorial/. https://shiny.rstudio.com/tutorial/.