User meta-data

Shiny applications can access the username and groups of the current logged in user through the session parameter of the shinyServer function.

Group meta-data is populated when using most authentication providers, except LDAP. This happens because group memberships are only stored in the LDAP server.

shinyServer(function(input, output, session) {
  output$username <- reactive({

  output$groups <- reactive({

Your application could use this information to display customized messages or to enable functionality for a specific subset of users.

Most environments have unique usernames where each session$user identifies a single user and session$groups the name of the groups the user is a member of. In large organizations with hundreds of users, it is possible to have two users with, for example, the same last name and initials, which could result in a duplicated username. If you're expecting such a large number of logged in users to access your Shiny application, please be sure to consult your administrator to confirm whether this condition is possible in your environment. Note that session$groups may suffer the same issue of duplicates names when users are authenticating against some providers, Azure in particular. If you want to ensure uniqueness of the user or group identifiers RStudio Connect should be configured with the option Authorization.ContentCredentialsUseGUID. When enabled, your content will receive the user and groups GUIDs instead of their names in session$user and session$groups. Not only are these values guaranteed to be unique but they can also be used to query for additional information about the user and groups using the Connect Server API.


Version 0.14 of the shiny package introduced bookmarkable state. RStudio Connect includes full support for Shiny's bookmarkable state features. Bookmarkable state allows users to create and share custom URLs to Shiny applications that will automatically restore the inputs and outputs of an application. For example, a user may select a set of inputs that produces an interesting plot. Rather than instructing another user to click through the same input steps to view the plot, they can create a bookmarked URL and share the URL with others. For more information, visit the Shiny Development Center.

Plot Caching

Version 1.2 of the shiny package introduced plot caching. Plot caching can greatly improve the performance of an application visited by multiple users. Plot caching prevents the R process from re-creating identical plots for each visitor.

To use plot caching, simply replace calls to shiny::renderPlot with a call to shiny::renderCachedPlot and include a shiny::cacheKeyExpr. View the help page for shiny::renderCachedPlot for details (run ?shiny::renderCachedPlot from R).

In addition to this change, applications deployed on RStudio Connect should use a disk cache and specify a subdirectory of the application directory as the location for the cache. To do so, add this code to the top of your application:

shinyOptions(cache = diskCache("./cache"))

This option ensures that cached plots will be saved and used across the multiple R processes that RStudio Connect runs in support of an application. In addition, this configuration results in the cache being deleted and reset when new versions of the application are deployed.

Load Testing

The runtime settings of a Shiny application control how processes are managed: when to start and stop processes in reaction to traffic demands.

This support article explains process scheduling and provides some guidelines when changing your own application settings. Details for each setting are included in the Runtime/Scheduler configuration appendix of the RStudio Connect Admin Guide.

Shiny applications can be load tested using the shinyloadtest R package. The package includes support for applications deployed on RStudio Connect and applications that require authentication.

Tracking Visits

Connect records visits to Shiny applications and lets you see:

  • Which applications were viewed
  • When the applications were viewed
  • Who viewed the application
  • The length of each session

An overview of recent activity is available in the RStudio Connect dashboard. See the Content Settings Panel section to learn more.

Details about each visit are available through the Instrumentation APIs. Use these records to perform your own analysis. Code examples showing how to obtain this data can be found in the User Activity section of the RStudio Connect: Server API Cookbook.