This is an extension to help launch Shiny applications. Shiny is a package for Python and R that is designed to make it easy to build interactive web applications with the powerful data and scientific features of Python and R.
The main features of this extension are additional options in the Run button menu when editing an app.py
or app.R
file to "Run Shiny App" or "Debug Shiny App" (Python only).
It also provides a couple of code snippets in both Python and R:
shinyapp
for creating a new Shiny applicationshinymod
for creating a new Shiny moduleshinyexpress
for creating a new Shiny Express application (Python)
For a complete Shiny for Python experience in VS Code, please visit our docs for more information, including instructions for configuring the type checker and debugger for use with Shiny.
You can use the extension to create shareable links to your apps using Shinylive, a free service for sharing Shiny apps via static hosting. Shinylive links encode the app's code and data in the URL, so you can share your app with others without needing to deploy it to a server. When the link is opened, the app runs in the user's browser using special version of Python or R that can run in the browser.
To create a Shinylive link from your app, you have two choices:
-
For single-file apps, e.g.
app.py
orapp.R
, run the Create ShinyLive Link from Active File from the command palette with the app file open and active. -
For multi-file apps, select all of the files or directories you want to include in your Shinylive app in the Explorer pane. Then right click on the selection and choose Create ShinyLive Link from Selected Files.
The Shiny extension will ask you which app mode you want to use (display the app or show an editor next to the app) and what action to take (to open or copy the link).You can also configure these options in the extension settings.
For the reverse operation, use the Save App from Shinylive Link command in the command palette to save an app and its files from a Shinylive link. You'll be prompted to paste the Shinylive link and then to choose where the app will be saved in your workspace.
This extension contributes the following settings for Python and R.
shiny.python.port
: The port number to listen on when running a Shiny for Python app. (By default, 0, which will choose a random port for each workspace.)shiny.python.debugJustMyCode
: When running the "Debug Shiny App" command, only step through user-written code. Disable this to allow stepping through library code. (Defaults to true.)
Note that there is no setting for Python executable path or virtual environment. This extension uses whatever Python environment the VS Code Python extension thinks is active. If you find that the "Run Shiny App" and "Debug Shiny App" commands are launching with a different version of Python or different virtual environment than you intended, use the Python extension's Select Interpreter command to change it.
shiny.r.port
: The port number to listen on when running a Shiny app. (By default, 0, which will choose a random port for each workspace.)shiny.r.devmode
: Whentrue
(default), Shiny for R apps are launched in developer mode.
shiny.shinylive.appMode
: Should the Shinylive link open the app in"app"
mode, showing only the app and an optional header, or in"editor"
mode with the app alongside an editor and console pane. The default is"ask"
, which prompts you each time you create Shinylive link.shiny.includeHeader
: Include the "Shiny" header in the Shinylive link when opening in app mode?shiny.shinylive.openAction
: What action should be taken when opening a Shinylive link? Options are"open"
to open the link in an external browser,"copy"
the link to the clipboard, or"ask"
. The default is"ask"
, which prompts you each time you create a Shinylive link.shiny.shinylive.host
: The Shinylive host used when creating a Shinylive link. The default is"https://shinylive.io"
, which uses the latest released version of Shiny in Python or R. Or"https://posit-dev.github.io/shinylive"
, which uses the latest development version of Shiny in Python or R.