% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/shinylive-link.R
\name{shinylive_r_link}
\alias{shinylive_r_link}
\title{Create a Shinylive sharelink for R Shiny apps}
\usage{
shinylive_r_link(input = NULL, mode = "editor", header = TRUE, base_url = NULL)
}
\arguments{
\item{input}{App input. Can be:
\itemize{
\item R expression (no quotes needed): \code{shinylive_r_link({ shinyApp(ui, server) })}
\item Character string: R code for the app
\item File path: Path to app.R file
\item Vector of file paths: Multiple files for the app
\item Named list: \code{list("app.R" = code1, "utils.R" = code2)}
\item NULL: Read from clipboard
}}

\item{mode}{Shinylive display mode (default \code{"editor"}). \code{"editor"} shows an
editable code panel beside the running app; \code{"app"} shows only the running app.}

\item{header}{Logical, whether to show the Shinylive header bar. It applies only
when \code{mode = "app"} and is ignored in the default \code{"editor"} mode. Defaults to \code{TRUE}.}

\item{base_url}{Custom Shinylive base URL. If NULL (default), links point at https://shinylive.io.}
}
\value{
shinylive_link object containing the Shinylive URL and metadata
}
\description{
Generates a shareable URL for R Shiny applications that can run in the browser
using Shinylive. Supports expressions, character strings, file paths, named lists,
and clipboard input.
}
\section{Comments in expression input}{

Comments inside a \code{{ }} expression are recovered from R's source references, so
they survive interactively but are dropped inside a knitted 'Quarto' or
'R Markdown' document. Pass a string or a file path, or use the \code{livelink} chunk
engine, if you need them preserved. See \code{\link[=webr_repl_link]{webr_repl_link()}} for the details.
}

\examples{
# Expression input (no quotes needed!)
shinylive_r_link({
  ui <- fluidPage(titlePanel("Hello World"))
  server <- function(input, output) {}
  shinyApp(ui, server)
})

# Multiple files as a named list
shinylive_r_link(list(
  "app.R" = "library(shiny)\nshinyApp(fluidPage(), function(i, o) {})",
  "utils.R" = "helper <- function() 42"
))

# File path input
app_dir <- tempfile()
dir.create(app_dir)
app_path <- file.path(app_dir, "app.R")
writeLines("library(shiny)", app_path)
shinylive_r_link(app_path)

# Read the app from the clipboard
if (interactive()) {
  shinylive_r_link()
}
}
\seealso{
\code{\link[=shinylive_project]{shinylive_project()}} for multi-file apps; \code{\link[=decode_shinylive_link]{decode_shinylive_link()}}
and \code{\link[=preview_shinylive_link]{preview_shinylive_link()}} to read a link back; \link{livelink-knitr} to give
a document chunk its own link;
\code{vignette("webr-and-shinylive", package = "livelink")} for the guide.
}
