Add, remove, or list directory of static resources to Shiny's web server, with the given path prefix. Primarily intended for package authors to make supporting JavaScript/CSS files available to their components.
addResourcePath(prefix, directoryPath)
resourcePaths()
removeResourcePath(prefix)The URL prefix (without slashes). Valid characters are a-z, A-Z, 0-9, hyphen, period, and underscore. For example, a value of 'foo' means that any request paths that begin with '/foo' will be mapped to the given directory.
The directory that contains the static resources to be served.
Shiny provides two ways of serving static files (i.e., resources):
Static files under the www/ directory are automatically made available
under a request path that begins with /.
addResourcePath() makes static files in a directoryPath available
under a request path that begins with prefix.
The second approach is primarily intended for package authors to make supporting JavaScript/CSS files available to their components.
Tools for managing static resources published by Shiny's web server:
addResourcePath() adds a directory of static resources.
resourcePaths() lists the currently active resource mappings.
removeResourcePath() removes a directory of static resources.
addResourcePath('datasets', system.file('data', package='datasets'))
resourcePaths()
#> datasets
#> "/opt/R/4.5.2/lib/R/library/datasets/data"
removeResourcePath('datasets')
resourcePaths()
#> named character(0)
# make sure all resources are removed
lapply(names(resourcePaths()), removeResourcePath)
#> list()