Title: Run 'shiny' Applications in the Browser
Version: 0.3.0
Description: Exporting 'shiny' applications with 'shinylive' allows you to run them entirely in a web browser, without the need for a separate R server. The traditional way of deploying 'shiny' applications involves in a separate server and client: the server runs R and 'shiny', and clients connect via the web browser. When an application is deployed with 'shinylive', R and 'shiny' run in the web browser (via 'webR'): the browser is effectively both the client and server for the application. This allows for your 'shiny' application exported by 'shinylive' to be hosted by a static web server.
License: MIT + file LICENSE
URL: https://posit-dev.github.io/r-shinylive/, https://github.com/posit-dev/r-shinylive
BugReports: https://github.com/posit-dev/r-shinylive/issues
Imports: archive, brio, cli, fs, gh, glue, httr2 (≥ 1.0.0), jsonlite, pkgdepends, progress, rappdirs, renv, rlang, tools, whisker, withr
Suggests: httpuv (≥ 1.6.12), pkgcache, spelling, testthat (≥ 3.0.0)
Config/Needs/website: tidyverse/tidytemplate
Config/testthat/edition: 3
Encoding: UTF-8
Language: en-US
RoxygenNote: 7.3.2
NeedsCompilation: no
Packaged: 2024-11-12 21:58:26 UTC; garrick
Author: Barret Schloerke ORCID iD [aut, cre], Winston Chang ORCID iD [aut], George Stagg [aut], Garrick Aden-Buie ORCID iD [aut], Posit Software, PBC [cph, fnd]
Maintainer: Barret Schloerke <barret@posit.co>
Repository: CRAN
Date/Publication: 2024-11-12 23:10:02 UTC

shinylive: Run 'shiny' Applications in the Browser

Description

Exporting 'shiny' applications with 'shinylive' allows you to run them entirely in a web browser, without the need for a separate R server. The traditional way of deploying 'shiny' applications involves in a separate server and client: the server runs R and 'shiny', and clients connect via the web browser. When an application is deployed with 'shinylive', R and 'shiny' run in the web browser (via 'webR'): the browser is effectively both the client and server for the application. This allows for your 'shiny' application exported by 'shinylive' to be hosted by a static web server.

Author(s)

Maintainer: Barret Schloerke barret@posit.co (ORCID)

Authors:

Other contributors:

See Also

Useful links:


Manage shinylive assets

Description

Helper methods for managing shinylive assets.

Usage

assets_download(
  version = assets_version(),
  ...,
  dir = assets_cache_dir(),
  url = assets_bundle_url(version)
)

assets_ensure(
  version = assets_version(),
  ...,
  dir = assets_cache_dir(),
  url = assets_bundle_url(version)
)

assets_cleanup(..., dir = assets_cache_dir())

assets_remove(versions, ..., dir = assets_cache_dir())

assets_info(quiet = FALSE)

assets_version()

Arguments

version

The version of the assets to download.

...

Ignored.

dir

The asset cache directory. Unless testing, the default behavior should be used.

url

The URL to download the assets from. Unless testing, the default behavior should be used.

versions

The assets versions to remove.

quiet

In assets_info(), if quiet = TRUE, the function will not print the assets information to the console.

Value

assets_version() returns the version of the currently supported Shinylive.

All other methods return invisible().

Functions


Install shinylive assets from from a local directory

Description

Helper methods for testing updates to shinylive assets.

Usage

assets_install_copy(
  assets_repo_dir,
  ...,
  dir = assets_cache_dir(),
  version = package_json_version(assets_repo_dir)
)

assets_install_link(
  assets_repo_dir,
  ...,
  dir = assets_cache_dir(),
  version = package_json_version(assets_repo_dir)
)

Arguments

assets_repo_dir

The local repository directory for shinylive assets (e.g. posit-dev/shinylive)

...

Ignored.

dir

The asset cache directory. Unless testing, the default behavior should be used.

version

The version of the assets being installed.

Value

All method return invisible().

Functions

See Also

assets_download(), assets_ensure(), assets_cleanup()


Export a Shiny app to a directory

Description

This function exports a Shiny app to a directory, which can then be served using httpuv.

Usage

export(
  appdir,
  destdir,
  ...,
  subdir = "",
  quiet = getOption("shinylive.quiet", !is_interactive()),
  wasm_packages = NULL,
  package_cache = TRUE,
  max_filesize = NULL,
  assets_version = NULL,
  template_dir = NULL,
  template_params = list(),
  verbose = NULL
)

Arguments

appdir

Directory containing the application.

destdir

Destination directory.

...

Ignored

subdir

Subdirectory of destdir to write the app to.

quiet

Suppress console output during export. Follows the global shinylive.quiet option or defaults to FALSE in interactive sessions if not set.

wasm_packages

Download and include binary WebAssembly packages as part of the output app's static assets. Logical, defaults to TRUE. The default value can be changed by setting the environment variable SHINYLIVE_WASM_PACKAGES to TRUE or 1 to enable, FALSE or 0 to disable.

package_cache

Cache downloaded binary WebAssembly packages. Defaults to TRUE.

max_filesize

Maximum file size for bundling of WebAssembly package assets. Parsed by fs::fs_bytes(). Defaults to "100M". The default value can be changed by setting the environment variable SHINYLIVE_DEFAULT_MAX_FILESIZE. Set to Inf, NA or -1 to disable.

assets_version

The version of the Shinylive assets to use in the exported app. Defaults to assets_version(). Note, not all custom assets versions may work with this release of shinylive. Please visit the shinylive asset releases website to learn more information about the available assets_version values.

template_dir

Path to a custom template directory to use when exporting the shinylive app. The template can be copied from the shinylive assets using: fs::path(shinylive:::assets_dir(), "export_template").

template_params

A list of parameters to pass to the template. The supported parameters depends on the template being used. Custom templates may support additional parameters (see template_dir for instructions on creating a custom template or to find the current shinylive assets' templates).

With shinylive assets > 0.4.1, the default export template supports the following parameters:

  1. title: The title of the app. Defaults to "Shiny app".

  2. include_in_head, include_before_body, include_after_body: Raw HTML to be included in the ⁠<head>⁠, just after the opening ⁠<body>⁠, or just before the closing ⁠</body>⁠ tag, respectively.

verbose

Deprecated, please use quiet instead.

Value

Nothing. The app is exported to destdir. Instructions for serving the directory are printed to stdout.

Examples


app_dir <- system.file("examples", "01_hello", package = "shiny")
out_dir <- tempfile("shinylive-export")

# Export the app to a directory
export(app_dir, out_dir)

# Serve the exported directory
if (require(httpuv)) {
  httpuv::runStaticServer(out_dir)
}


Quarto extension for shinylive

Description

Integration with https://github.com/quarto-ext/shinylive

Usage

quarto_ext(
  args = commandArgs(trailingOnly = TRUE),
  ...,
  pretty = is_interactive(),
  con = "stdin"
)

Arguments

args

Command line arguments passed by the extension. See details for more information.

...

Ignored.

pretty

Whether to pretty print the JSON output.

con

File from which to take input. Default: "stdin".

Value

Nothing. Values are printed to stdout.

Command arguments

The first argument must be "extension". This is done to match py-shinylive so that it can nest other sub-commands under the extension argument to minimize the api clutter the user can see.

CLI Interface