Skip to contents

Generates a shareable URL for R Shiny applications that can run in the browser using Shinylive. The app files are encoded and embedded in the URL.

Usage

shinylive_r_link(files, mode = "editor", header = TRUE, base_url = NULL)

Arguments

files

Named list where names are filenames and values are file content as character strings. For single-file apps, can also pass a character string as the app.R content.

mode

Shinylive mode: "editor" (show code editor) or "app" (show app only)

header

Logical. Whether to show header in app mode (default: TRUE)

base_url

Custom Shinylive base URL. If NULL, uses default Shinylive URL

Value

shinylive_link object containing the Shinylive URL and metadata

Examples

# Simple single-file Shiny app
app_code <- '
library(shiny)
ui <- fluidPage(
  titlePanel("Hello Shinylive!"),
  sidebarLayout(
    sidebarPanel(
      sliderInput("obs", "Number of observations:", min = 1, max = 1000, value = 500)
    ),
    mainPanel(plotOutput("distPlot"))
  )
)
server <- function(input, output) {
  output$distPlot <- renderPlot({
    hist(rnorm(input$obs), col = "darkgray", border = "white")
  })
}
shinyApp(ui = ui, server = server)
'

link <- shinylive_r_link(app_code, mode = "app")
print(link)
#> 
#> ── Shinylive R App ──
#> 
#> <https://shinylive.io/r/app/#code=NobwRAdghgtgpmAXGKAHVA6ASmANGAYwHsIAXOMpMAHQgBsBLAIwCcoWBPACgGcALBhA4BKWgFcGAAgA8AWkkAzOhIAmABSgBzOF1qTJpBqTpwNEOHV1gAEhbpFJAZQFDGANzgBCamGG49kjwMKnBM7AAyUBxEYqS6EPr6QSFhLGYW8YmJPIwhLACSEKixVkRMPD64kj4AcmIwTHAskkQKLeVNblCGJDyIlZIwgpIAvJIAjFUwUAAeoxMADEtVXcpw8wCsS6IJiX4B+tOC6Zao9qQA8rHFcT4qDDykauc+wjv6Ozs8nU0y8gpiCAEHoQLiCG5VGKkG7CSQgAJQm4AEnuj2eRFIf0kLAoeXRcXhu30AkeXBYECILBgYKKsSRZR4fkkxDo8zu7AA1po2BwBkxKXk2WAAO4CcivAIAXx2kto-EEHAAguguBJ5hIqt8WB5mmMtTqdngwKQOKgEMhyDNSGBJQBdIA>
#> 
#> Files (1):
#> app.R
#> 
#> Engine: "R"
#> Mode: "app"

# Multi-file Shiny app
files <- list(
  "app.R" = app_code,
  "utils.R" = "helper_function <- function(x) { x * 2 }",
  "data.csv" = "x,y\n1,2\n3,4\n5,6"
)

link <- shinylive_r_link(files, mode = "editor")