[!IMPORTANT]
This package is currently in the prototype/experimental stage. It is not yet available on CRAN and may have bugs or limitations.
We do not recommend using this package for production applications at this time.
Export Shiny Applications as Desktop Applications using Electron
This R package allows you to convert Shiny web applications into standalone desktop applications for using Electron. This means your users can run your Shiny apps without having R installed on their machines.
Installation
You can install the development version of shinyelectron from GitHub with:
# From CRAN (not available yet)
# install.packages("shinyelectron")
# From GitHub
# install.packages("remotes")
remotes::install_github("coatless-rpkg/shinyelectron")
Prerequisites
[!IMPORTANT]
We are currently working on making the installation process as smooth as possible. Please bear with us as we work through identifying the necessary dependencies for each platform.
- R (>= 4.4.0)
- Node.js (>= 22.0.0)
- npm (>= 11.5.0)
For building platform-specific installers:
- Windows: Windows 11+ and Visual Studio Build Tools
- macOS: macOS 10.13+ and Xcode CLI
- Linux: Appropriate development tools for your distribution
Usage
Quickstart
The export()
function allows you to convert a Shiny application into a standalone Electron application.
library(shinyelectron)
# Export a Shiny application to an Electron application
shinyelectron::export(
appdir = "path/to/your/shiny/app",
destdir = "path/to/export/destination"
)
For example, to convert the “Hello World” Shiny app from the shiny package into a standalone Electron app:
# Copy "Hello World" from `{shiny}`
system.file("examples", "01_hello", package="shiny") |>
fs::dir_copy("hello-shiny-app", overwrite = TRUE)
shinyelectron::export("hello-shiny-app", "shinyelectron-converted-app")
Advanced Options
You can customize the export process using the following options:
shinyelectron::export(
appdir = "path/to/your/shiny/app",
destdir = "path/to/export/destination",
app_name = "My-App-Title", # Defaults to the name of the appdir
app_type = "r-shinylive", # We only support "r-shinylive"
platform = c("mac"), # c("win", "mac", "linux")
arch = c("arm64"), # c("x64", "arm64")
overwrite = TRUE, # Overwrite existing files in destdir
run_after = TRUE, # Launch the app after building for testing
open_after = TRUE, # Open the generated project after export
verbose = TRUE # Display detailed progress information
)
How It Works
- The package creates an Electron application structure in the destination directory
- It copies your Shiny application files into this structure
- It configures the Electron app to start an R process and run your Shiny app
- It optionally bundles a minimal R environment
- It builds platform-specific installers using electron-builder
Acknowledgements
This project builds upon several notable efforts to integrate R Shiny applications with the Electron framework.
Prior packaging attempts:
-
electricShine: A package that streamlines the creation of distributable Shiny Electron apps through its
electrify
function, which automates building and packaging processes for Windows. -
Photon: An RStudio add-in that leverages Electron to build standalone Shiny apps for macOS and Windows by cloning an R specific
electron-quick-start
repository and including portable R versions. - RInno: Creates standalone R applications with Electron on Windows.
- DesktopDeployR: An alternative framework for deploying self-contained R-based applications that provides a portable R environment and private package library.
Talks, Tutorials, and Templates:
- User! 2018 Talk: A presentation by @ksasso at the 2018 UseR! conference that demonstrates how to convert Shiny apps into standalone desktop applications using Electron.
- Developer Tutorials: Valuable step-by-step guides from contributors like @lawalter and @dirkschumacher that demonstrate practical integration techniques and solutions, c.f. shiny-electron-walter-tutorial
- Zarathu Corporation Templates: Specialized templates for macOS ARM (M1/M2/..) and Windows platforms that have significantly contributed to cross-platform deployment solutions described in R-Bloggers: Creating Standalone Apps from Shiny with Electron post.
References
electricShine
(R Package)RInno
(R package)Photon
(RStudio Addin)COVAIL
Electron Quick Start (GitHub)DesktopDeployR
(GitHub)- Electron ShinyApp Deployment UseR! 2018 (GitHub, @ksasso)
- How to Make an R Shiny Electron App (GitHub, @lawalter)
- R shiny and electron (GitHub, @dirkschumacher)
- Creating Standalone Apps from Shiny with Electron in macOS 2023 (GitHub, macOS ARM (M1/M2/…))
- Creating Standalone Apps from Shiny with Electron in Windows 2023 (GitHub, @jhk0530)
- Creating Standalone Apps from Shiny with Electron 2023 (R-bloggers, @jhk0530)
- Shiny meets Electron: Turn your Shiny app into a standalone desktop app in no time @ UseR! 2018 (Presentation Source)
- Electron Documentation