The peeky package helps you extract, examine, and run
the source code from Shiny applications that have been converted to run
in the browser using Shinylive.
It works with both standalone applications and Quarto documents containing Shinylive
components through the quarto-shinylive
extension, supporting both R and Python Shiny applications.
Shinylive converts existing Shiny applications to run entirely in the web browser using WebAssembly versions of R (webR) and Python (Pyodide), eliminating the need for a computational server. This means all application files are accessible to users by design as they are downloaded to the user’s browser when the application is loaded.
The Shinylive ecosystem consists of four main components:
The peeky package was developed to demonstrate a
fundamental truth about Shinylive applications stressed by its
developers: “There are no secrets.”
Unlike traditional Shiny applications where server-side code remains private, Shinylive apps run entirely in the web browser, making all associated files accessible to users. This includes the source code, data, and any other files used by the application. As a result, Shinylive applications are transparent by design.
This package was developed as part of ongoing discussions in STATS 290 about Shiny application security, transparency, and deployment options. It serves as a practical demonstration of the differences between traditional server-side applications and modern browser-based alternatives.
You can install the development version of peeky from GitHub with:
# install.packages("remotes")
remotes::install_github("coatless-rpkg/peeky")To use the package, load it into your R session:
library(peeky)Inside the package, there are three main functions:
| Function | Description |
|---|---|
peek_shinylive_app() |
Universal function that handles both standalone apps and Quarto docs |
peek_standalone_shinylive_app() |
Specifically for standalone Shinylive applications |
peek_quarto_shinylive_app() |
Specifically for Quarto documents with Shinylive components |
We suggest using the peek_shinylive_app() function as it
can handle both standalone Shinylive applications and Quarto documents
with Shinylive components. For instance, if we take the main Shinylive
extension website, we get:
# Choose where the files are written (here, a temporary directory)
out_dir <- file.path(tempdir(), "shinylive-apps")
peeky::peek_shinylive_app("https://quarto-ext.github.io/shinylive/", output_dir = out_dir)
#>
#> ── Shinylive Applications ──────────────────────────────────────────────────────
#>
#> ── Shiny for Python Applications ──
#>
#> Run in Terminal:
#> shiny run --reload --launch-browser "/tmp/RtmpXXXXXX/shinylive-apps/app_1/app.py"
#> shiny run --reload --launch-browser "/tmp/RtmpXXXXXX/shinylive-apps/app_2/app.py"
#> shiny run --reload --launch-browser "/tmp/RtmpXXXXXX/shinylive-apps/app_3/app.py"
#> shiny run --reload --launch-browser "/tmp/RtmpXXXXXX/shinylive-apps/app_4/app.py"This would be equivalent to if we ran the following:
peeky::peek_quarto_shinylive_app(
"https://quarto-ext.github.io/shinylive/",
output_path = out_dir
)The output location is a required argument, so the package never
writes to your working directory unless you ask it to: a relative path
such as "my-apps" is created under the current working
directory, while an absolute path is used as-is. Each application is
placed in a subdirectory named app_1, app_2,
etc. We can also set the output format to quarto to extract
the files into a single Quarto document.
# Extract the applications into a single Quarto document
peeky::peek_quarto_shinylive_app(
"https://quarto-ext.github.io/shinylive/",
output_format = "quarto",
output_path = file.path(tempdir(), "shinylive-apps.qmd")
)
#>
#> ── Quarto Document with Shinylive Applications ─────────────────────────────────
#>
#> ── Setup and Preview Steps ──
#>
#> Step 1: Change to the document directory:
#> cd "/tmp/RtmpXXXXXX"
#>
#> Step 2: Install the Shinylive extension:
#> quarto add quarto-ext/shinylive
#>
#> Step 3: Preview the document:
#> quarto preview "shinylive-apps.qmd"
#>
#> ── Contents ──
#>
#> • R applications: 0
#> • Python applications: 4We can switch to the peek_standalone_shinylive_app()
function if we know that the URL is a standalone Shinylive application.
For example, if we take the example application used in the conversion
tutorial from an
app.R to an R Shinylive app on GitHub, we get:
peeky::peek_standalone_shinylive_app(
"https://tutorials.thecoatlessprofessor.com/convert-shiny-app-r-shinylive/",
output_dir = file.path(tempdir(), "standalone-app")
)
#>
#> ── Standalone Shinylive Application ────────────────────────────────────────────
#> Type: R Shiny
#> Run in R:
#> shiny::runApp("/tmp/RtmpXXXXXX/standalone-app")
#>
#> ── Contents ──
#>
#> .md files:
#> • README.md
#> .R files:
#> • app.R
#>
#> Total files: 2
#>
#> Location: '/tmp/RtmpXXXXXX/standalone-app'AGPL (>= 3)
This package represents a more refined and comprehensive approach compared to our earlier tutorial that focused solely on standalone R Shinylive applications.
This package is for educational purposes. Users should:
Thanks to the Shinylive, webR and Pyodide teams for enabling browser-based data science.