Skip to contents

Returns the htmltools::htmlDependency() for the vendored bslibreact.js bundle (and its stylesheet, when one is built), which sets window.bslibreact. Attach it only for a client with no build step that reads the kit from that global, for example page_react(page_deps(app_theme), bslibreact_dep(), theme = app_theme). A client built with Vite bundles the kit itself and does not need it.

Usage

bslibreact_dep()

Load order

The bundle reads window.shinyreact as it evaluates, so it must run after shinyreact's own bundle. shinyreact::page_react() attaches that first, and both scripts use defer, which keeps document order. The app's own ui.js also runs before this bundle, so a client script reads window.bslibreact inside a window load listener.

Before pkg-js has built anything

This function never errors for a missing bundle file: an htmltools::htmlDependency() does not check that its files exist when it is constructed, only once something actually tries to serve them, so this returns a structurally valid dependency even when inst/lib/bslibreact/bslibreact.js has not been vendored in yet. This matters during this repository's own development, where pkg-js's build and pkg-r's own checks can run before make update-dist has ever populated inst/lib/bslibreact/.

Examples

dep <- bslibreact_dep()
dep$name
#> [1] "bslibreact"
dep$script
#> $src
#> [1] "bslibreact.js"
#> 
#> $defer
#> [1] ""
#>