Electron Desktop App for Shiny

Code Properties

  • Language: R
  • Packages: RInno, here, installr

Overview

Build a standalone desktop application installer for R Shiny apps using RInno and Electron. This allows distributing Shiny apps as native Windows applications without requiring users to have R installed.

Sources

Installation

Install required packages:

pak::pak("ficonsulting/RInno")

Ensure Inno Setup is installed and on the system PATH:

require(RInno)
 
if (Sys.which("ISCC.exe") == "") {
  RInno::install_inno()
}

Code

require(RInno)
require(here)
require(installr)
 
# define app dependencies
libs <- c(
  "shiny",
  "shinyjs",
  "shinyWidgets",
  "shinycssloaders",
  "purrr",
  "lubridate",
  "tibble",
  "dplyr",
  "highcharter",
  "stringr",
  "rintrojs",
  "DT",
  "knitr",
  "rmarkdown",
  "qs"
)
 
# ensure Inno Setup is available
if (Sys.which("ISCC.exe") == "") {
  RInno::install_inno(quick_start_pack = TRUE)
}
 
# create the application package
RInno::create_app(
  app_name = "My Shiny App",
  app_dir = here::here(),
  dir_out = "build",
  pkgs = libs,
  pkgs_path = "bin",
  repo = getOption("repos"),
  remotes = NULL,
  include_R = TRUE,
  R_version = .rs.rVersionString(),
  overwrite = TRUE
)
 
# compile the installer
RInno::compile_iss()

Usage

  1. Set up your Shiny app directory with standard structure
  2. Update the libs vector with your app’s dependencies
  3. Replace "My Shiny App" with your application name
  4. Run the script to generate an installer in the build/ directory

Output Structure

build/
  |- app_name_setup.exe    # Windows installer
  |- app/                  # Application files
  |- bin/                  # R packages

Appendix

Note created on 2024-09-23 and last modified on 2024-12-13.

See Also


(c) No Clocks, LLC | 2024