Skip to contents

Builds a distributable Electron application from a converted Shiny app. Creates platform-specific installers and executables.

Usage

build_electron_app(
  app_dir,
  output_dir,
  app_name = NULL,
  app_type = "r-shiny",
  runtime_strategy = "shinylive",
  sign = FALSE,
  platform = NULL,
  arch = NULL,
  icon = NULL,
  config = NULL,
  overwrite = FALSE,
  verbose = TRUE
)

Arguments

app_dir

Character string. Path to the converted Shiny/shinylive application.

output_dir

Character string. Path where the built Electron app will be saved.

app_name

Character string. Name of the application. If NULL, uses the name of the app_dir directory.

app_type

Character string. Language of the Shiny app: "r-shiny" (default) or "py-shiny". Unlike export(), this function does not autodetect the language from source files – the default "r-shiny" is used when app_type is not supplied. Supply "py-shiny" explicitly for Python Shiny applications. The legacy values "r-shinylive" / "py-shinylive" are accepted with a deprecation warning and translate to the canonical language plus runtime_strategy = "shinylive".

runtime_strategy

Character string. Runtime strategy: "shinylive", "bundled", "system", "auto-download", or "container". Default "shinylive".

sign

Logical. Whether to enable code signing for the built application. Default is FALSE.

platform

Character vector. Target platforms: "win", "mac", "linux". If NULL, builds for current platform. The build.platforms key of config is not read here; export() reads it.

arch

Character vector. Target architectures: "x64", "arm64". If NULL, uses current architecture. The build.architectures key of config is not read here; export() reads it.

icon

Character string. Path to application icon file, absolute or relative to the working directory. A PNG (1024x1024 or larger) or an .icns file serves every platform; an .ico file serves Windows only. The icon and icons keys of config are not read here.

config

List. Configuration from _shinyelectron.yml file (optional). Used for template variables like window dimensions, port, and app version. File paths in it, such as splash.image, tray.icon, signing.win.certificate_file and installer.license_file, are used as given: absolute, or relative to the working directory, like the icon argument. export() reads _shinyelectron.yml itself and first resolves those paths against the app directory. A splash image or tray icon that does not exist is left out with a warning; a missing license file stops the build.

overwrite

Logical. Whether to overwrite existing output directory. Default is FALSE.

verbose

Logical. Whether to display detailed progress information. Default is TRUE.

Value

Character string. Path to the built Electron application directory.

Details

This function creates a complete Electron application by:

  • Setting up the Electron project structure

  • Copying application files and templates

  • Installing npm dependencies

  • Building platform-specific distributables

Examples

if (FALSE) { # interactive()
# Build Electron app for current platform
build_electron_app(
  app_dir = "path/to/shinylive/app",
  output_dir = "path/to/electron/build",
  app_name = "My Shiny App",
  app_type = "r-shiny"
)

# Build for multiple platforms
build_electron_app(
  app_dir = "path/to/app",
  output_dir = "path/to/build",
  app_name = "My App",
  app_type = "r-shiny",
  platform = c("win", "mac", "linux")
)
}