config

config function

Get or set shinywidgets’ app-wide settings.

Usage Source

config(**kwargs: Any)

Called with no arguments, returns a dict of the current settings. Called with keyword arguments, sets those settings and returns the updated dict. Unknown setting names raise TypeError.

Currently available settings:

  • native_events (bool, default False, env var SHINYWIDGETS_NATIVE_EVENTS): some widgets sync their own event streams to Python by default (e.g. plotly.py’s per-point click/hover/ selection reports), which renderers mute unless the app uses them. Set native_events=True to receive every widget’s native events app-wide.
  • cdn (str, default "https://cdn.jsdelivr.net/npm/", env var SHINYWIDGETS_CDN): the base URL of the CDN that widget JavaScript falls back to when no local copy of a widget’s extension is found. output_widget() bakes the value into the UI’s data attributes, so config(cdn=...) must run before the UI is built (e.g., the top of app.py); the env var remains the deployment-time alternative.
  • cdn_only (bool, default False, env var SHINYWIDGETS_CDN_ONLY): always load widget JavaScript from the CDN, never from a local copy. Like cdn, output_widget() bakes it into the UI’s data attributes, so it must be set before the UI is built.
  • extension_warning (bool, default False, env var SHINYWIDGETS_EXTENSION_WARNING): warn when no local path to a widget’s extension is found (the widget still renders via the CDN fallback). Read per render, so it only needs to be set before the first render.