Main entry point function that wraps the conversion, building, and optionally running of a Shiny application as an Electron desktop application.
Usage
export(
appdir,
destdir,
app_name = NULL,
app_type = NULL,
runtime_strategy = NULL,
sign = FALSE,
platform = NULL,
arch = NULL,
icon = NULL,
overwrite = FALSE,
build = TRUE,
run_after = FALSE,
open_after = FALSE,
verbose = TRUE
)Arguments
- appdir
Character string. Path to the directory containing the Shiny application.
- destdir
Character string. Path to the destination directory where the Electron app will be created.
- app_name
Character string. Display name of the application. If NULL, uses
app.namefrom_shinyelectron.yml, then the name of the app directory. Unlessapp.slugis set, this argument also gives the app's slug, its identity for installed copies and updates; without it the slug comes from the name of the app directory, never fromapp.name.- app_type
Character string or NULL. Language of the Shiny app:
"r-shiny"or"py-shiny". If NULL (default), the type is autodetected from files inappdir. The legacy values"r-shinylive"and"py-shinylive"are accepted with a deprecation warning and translate to the canonical language plusruntime_strategy = "shinylive".- runtime_strategy
Character string or NULL. How R or Python reaches the end user:
"shinylive","bundled","system","auto-download", or"container". Default"shinylive"when neither argument nor config sets one.- sign
Logical. Whether to enable code signing for the built application. When TRUE, electron-builder will attempt to sign the app using credentials from environment variables or the config file. Default is FALSE.
- platform
Character vector. Target platforms: "win", "mac", "linux". If NULL, uses
build.platformsfrom_shinyelectron.yml, then the current platform. macOS apps build only on macOS, so a"mac"target stops the export on Windows and Linux unlessbuild = FALSE.- arch
Character vector. Target architectures: "x64", "arm64". If NULL, uses
build.architecturesfrom_shinyelectron.yml, then the current architecture. Each ofplatformandarchreplaces only its own list, soplatform = "win"still builds for every architecture inbuild.architectures.- icon
Character string. Path to application icon file, absolute or relative to the working directory. A PNG (1024x1024 or larger) or an
.icnsfile serves every platform; an.icofile serves Windows only. Overridesiconandiconsin_shinyelectron.yml, whose paths are relative toappdir.- overwrite
Logical. Whether to overwrite existing output directory. Default is FALSE.
- build
Logical. Whether to build distributable packages. Default is TRUE.
- run_after
Logical. Whether to run the application in development mode after export. Default is FALSE.
- open_after
Logical. Whether to open the generated project directory after export. Default is FALSE.
- verbose
Logical. Whether to display detailed progress information. Default is TRUE.
Details
This is the main function of the package that orchestrates the entire process:
Validates the input Shiny application
Converts the Shiny app to the specified format (shinylive by default)
Sets up the Electron project structure
Optionally builds distributable packages
Optionally runs the application for testing
Supported Combinations
Two languages, five delivery strategies.
r-shinyorpy-shinyplusruntime_strategy = "shinylive": app compiles to WebAssembly and runs inside the Electron window with no runtime on disk.r-shinyorpy-shinyplus"auto-download","bundled","system", or"container": app runs against a real R or Python process supplied by the chosen strategy.
Examples
if (FALSE) { # interactive()
# Simplest call: app_type autodetects, runtime_strategy defaults to shinylive
export(
appdir = "path/to/shiny/app",
destdir = "path/to/electron/output"
)
# Run against a real R process instead of shinylive
export(
appdir = "path/to/shiny/app",
destdir = "path/to/output",
runtime_strategy = "bundled"
)
# Pin language explicitly when autodetection is ambiguous
export(
appdir = "path/to/shiny/app",
destdir = "path/to/output",
app_type = "r-shiny",
runtime_strategy = "system"
)
}