Start
Build
Improve
Start Your first Shiny app
back to top
We recommend that you start your Shiny journey with our beginner to intermediate tutorials. Then, you can refresh what you learned in the tutorial and learn the lay of the land of Shiny starting with the articles in this section.
The Shiny package comes with eleven built-in examples that demonstrate how Shiny works. This article reviews the first three examples, which demonstrate the basic structure of a Shiny app. Read more ...
A Shiny application is simply a directory containing an R script called app.R which is made up of a user interface object and a server function. This folder can also contain any any additional data, scripts, or other resources required to support the application. Read more ...
This article discusses running an app in a separate process and live reloading of apps. Read more ...
Start Help
back to top
Find out where to go for help and best practices for asking questions.
Writing code can be tricky. Sometimes you will want more advice than you can find in R's help pages. This article will show you where to seek help, how to get it. Read more ...
The Shiny cheat provides a tour of the shiny package and explains how to build and customize an interactive app. Read more ...
Build Standalone apps
back to top
Enhance your understanding of building individual apps.
You may have noticed that there are several different ways that Shiny apps are defined and launched. This article provides an overview of the different ways of defining and launching Shiny applications. Read more ...
Before of version 0.10.2, Shiny applications needed to be split into two separate files that include the code needed to define the UI and server components, respectively. This method is still supported in later versions of Shiny. Read more ...
Build Interactive documents
back to top
Embed your app in an interactive document.
Interactive documents are a new way to build Shiny apps. An interactive document is an R Markdown file that contains Shiny widgets and outputs. You write the report in markdown, and then launch it as an app with the click of a button. Read more ...
Interactive documents are a new way to build Shiny apps. An interactive document is an R Markdown file that contains Shiny widgets and outputs. You write the report in markdown, and then launch it as an app with the click of a button. Read more ...
The RStudio IDE contains many features that make it easy to write and run interactive documents. This article will highlight some of the most useful. Read more ...
The R Markdown cheat sheet is a quick reference guide for writing reproducible reports with R Markdown. Read more ...
This article discusses how to set output directly from the render function when working with just snippets of Shiny code. Read more ...
After interacting with a Shiny application and getting it certain state, your users may want to download a report in HTML or PDF format. You can easily add the ability to generate a report with knitr and rmarkdown at the click of a button. Read more ...
Build Dashboards
back to top
Build dashboards with predefined UI and layouts.
You have two package options for building Shiny dashboards -- flexdashboard and shinydashboard. Read more ...
Build Gadgets
back to top
Use Shiny to make your own interactive tools that streamline your data analysis workflow.
Shiny Gadgets are interactive tools that enhance your R programming experience. Where a Shiny app represents the output of an analysis, Shiny Gadgets are designed to be used in the course of analysis. Read more ...
While technically, any kind of Shiny UI could be used for a Shiny Gadget, we've created a miniUI package that we think is particularly well suited for Gadget use. We recommend that you start with miniUI based UI for your gadget, unless you have a specific reason not to. Read more ...
Build Reactivity
back to top
Understand reactivity at a conceptual level to build apps that are more efficient, robust, and correct.
It's easy to build interactive applications with Shiny, but to get the most out of it, you'll need to understand the reactive programming model used by Shiny. In Shiny, there are three kinds of objects in reactive programming -- reactive sources, reactive conductors, and reactive endpoints, which are represented with these symbols. Read more ...
Sometimes it's useful for an observer/endpoint to access a reactive value or expression, but not to take a dependency on it. For example, if the observer performs a long calculation or downloads large data set, you might want it to execute only when a button is clicked. Read more ...
At the core of Shiny is its reactive engine -- this is how Shiny knows when to re-execute each component of an application. We'll trace into some examples to get a better understanding of how it works. Read more ...
Reactivity is what makes your Shiny apps responsive. It lets the app instantly update itself whenever the user makes a change. You don't need to know how reactivity occurs to use it, but understanding reactivity will make you a better Shiny programmer. Read more ...
On the server side, Shiny applications use the input object to receive user input from the client web browser. The values in input are set by UI objects on the client web page. Read more ...
Build Data
back to top
Load data to and export data from your Shiny app, including relational databases.
As Shiny apps grow and become more complex, a recurring issue has been that of integrating an external database into an app. While this is already possible, so far it's been mostly up to the app authors to figure out the appropriate database driver for R and how to manage the database connections within the app itself. The goal of this series of articles is to demystify this process and to introduce some brand new features that should make it easier. Read more ...
SQL injections are attacks to apps, in which the attacker exploits a security vulnerability to send whatever SQL statements they wish to the database. With the latest release of DBI, we have a new function whose purpose is to safely interpolate values into an SQL string, therefore protecting you from injection attacks. Read more ...
The pool package a new level of abstraction when connecting to a database -- instead of directly fetching a connection from the database, you will create an object (called a pool) with a reference to that database. Read more ...
This article discusses how to customize your pool, by providing extra arguments to dbPool, how to handle transactions using a pool, and future work. Read more ...
The advantage of using pool with dplyr, rather than just using dplyr to query a database, is performance and connection management. In order to reap these benefits within a Shiny app, however, you need to be careful about where you create your pool and where you use tbl (or equivalent). Read more ...
Shiny apps often need to save data, either to load it back into a different session or to simply log some information. However, common methods of storing data from R may not work well with Shiny. Read more ...
Build User interface
back to top
Control the layout, user interface, and general appearance of your Shiny apps.
Shiny includes a number of facilities for laying out the components of an application. This guide describes the a variety of application layout features. Read more ...
Shiny can display your apps in two different ways -- normal mode and showcase mode. Read more ...
Tabsets are created by calling the tabsetPanel function with a list of tabs created by the tabPanel function. Each tab panel is provided a list of output elements which are rendered vertically within the tab. Read more ...
In this article, you will learn how to supplement the functions in your UI with raw HTML to create highly customized Shiny apps. You do not need to know HTML to use Shiny, but if you do, you can use the methods in this article to enhance your app. Read more ...
Many Shiny apps use a UI object file to build their user interfaces. While this is a fast and convenient way to build user interfaces, some applications will inevitably require more flexiblity. For this type of application, you can define your user interface directly in HTML. Read more ...
Shiny apps are often more than just a fixed set of controls that affect a fixed set of outputs. Inputs may need to be shown or hidden depending on the state of another input, or input controls may need to be created on-the-fly in response to user input. Read more ...
Templates can be used to generate complete web pages, and they can also be used to generate the HTML for components that are included in a Shiny app. Read more ...
Shiny provides a list of functions named tags. Each function in the list creates an HTML tag that you can use to layout your Shiny App. But what if you are unfamiliar with HTML tags? The glossary in this article explains what the most popular tags in tags do. Read more ...
If your Shiny app contains computations that take a long time to complete, a progress bar can improve the user experience by communicating how far along the computation is, and how much is left. Read more ...
As of version 0.14, Shiny has built-in support for displaying modal dialogs. Read more ...
As of version 0.14, Shiny can display notifications on the client browser by using the showNotification function. Read more ...
Easily customize the look of Shiny apps and R Markdown documents with the bslib and thematic packages. Read more ...
When you want to have R generate a plot and send it to the client browser, the renderPlot function will in most cases do the job. But when you need finer control over the process, you might need to use the renderImage function instead. Read more ...
This article describes how to use the improved renderTable Shiny function. Read more ...
To build DataTables in R, we recommend using the renderDataTable function in the DT package. By default, the data is paginated, showing 10 rows per page. Read more ...
This article describes five patterns to use with Shiny's action buttons and action links, which are are different from other Shiny widgets because they are intended to be used exclusively with observeEvent or eventReactive. Read more ...
Shiny slider controls are extremely capable and customizable. Features supported include the ability to input both single values and ranges, custom formats for value display (e.g for currency), and the ability to animate the slider across a range of values. Read more ...
Shiny has the ability to offer file downloads that are created on the fly, which makes it easy to build data exporting features. Read more ...
Sometimes you'll want users to be able to upload their own data to your application. Shiny makes it easy to offer your users file uploads straight from the browser, which you can then access from your server logic. Read more ...
The JavaScript library selectize.js provides a much more flexible interface compared to the basic select input. It allows you to type and search in the options, use placeholders, control the number of options/items to show/select, and so on. In Shiny, you can use the selectizeInput function to create a selectize input. Read more ...
Build Graphics & visualization
back to top
Create interactive plots with base and ggplot2 graphics (no JavaScript required!).
As of version 0.12.0, Shiny has built-in support for interacting with static plots generated by R's base graphics functions, and those generated by ggplot2. Read more ...
A common use of mouse interactions is to select rows of data from an input data frame. Although you could write code that uses the x and y (or the corresponding min and max) values to filter rows from the data frame, there is an easier way to do it. Read more ...
This article contains information about using Shiny's image and plot interaction features to perform some more advanced tasks. Read more ...
Build Shiny extensions
back to top
Learn about packages that provide advanced features that can enhance your Shiny apps.
htmlwidgets is framework for embedding JavaScript visualizations into R. Read more ...
The shinyjs package lets you perform common useful JavaScript operations in Shiny apps that will greatly improve your apps without having to know any JavaScript. Read more ...
Shiny is a web application framework that makes it easy to build interactive web applications (apps) straight from R. A key feature of shiny is that users can create powerful apps driven by R without having to know HTML, CSS, or JavaScript. However, incorporating these technologies into your apps can greatly enhance the power of shiny. Read more ...
In this article, we expand the widget to create smooth transitions like those in the showcase dashboard app. We also provide code and examples for the other charts types shown in the dashboard -- a pie chart, a line + bar chart and a stacked area chart. Read more ...
The ability to send and receive messages greatly improves the capabilities of our widgets, as C3 offers a powerful API with a vast set of options and methods that allow you to modify a chart after it is initialized. Read more ...
In this article, we will show you how to use the same functions to create a dynamic interactive help system for Shiny apps, based on the JavaScript library introJS. Read more ...
In this article we’ll learn how we can create our own custom input bindings. In a Shiny context, input bindings are mainly used to send information from the client to R. Read more ...
In this article we’ll create an interactive dashboard. We learn how we can set up an interactive filter system that uses a brushable timeline component and the button groups developed in the previous article. In addition, we learn how to send events from JavaScript to R at different rates such that we don’t overflow R with computations when we slide our brush over the timeline. Read more ...
Build Customizing Shiny
back to top
Create custom Shiny widgets, layouts and outputs, or combine Shiny with other web technologies.
Adding custom styling to your app can help make it stand out. Here we go over the various ways to add your own CSS styles to your apps. Read more ...
Shiny comes equipped with a variety of useful input components, but as you build more ambitious applications, you may find yourself needing input widgets that we don't include. Fortunately, Shiny is designed to let you create your own custom input components. Read more ...
Right out of the box, Shiny makes it easy to include plots, simple tables, and text as outputs in your application; but we imagine that you'll also want to display outputs that don't fit into those categories. Read more ...
This article will show you how to add Google Analytics to a Shiny app. Read more ...
Want to add some JavaScript code to your Shiny app, and don't know where to put it? You have several options. Read more ...
Sometimes, you want some custom behavior between JavaScript and R that isn't a natural fit for a custom input or output binding. In these cases, you can skip the machinery around input/output bindings, and more or less directly send messages back and forth between JavaScript and R. Read more ...
A number of JavaScript events are supported in Shiny as of version 0.13.0. These events can be used to keep track of the app's progress, or even manipulate the values of inputs/outputs. Read more ...
Improve Code quality
back to top
Find out about best practices for writing better Shiny code (that result in better and more performant Shiny apps) and for troubleshooting and debugging your apps.
Debugging Shiny applications can be challenging. Because Shiny is reactive, code execution isn't as linear as you might be used to, and your application code runs behind a web server and the Shiny framework itself, which can make it harder to access. Read more ...
When you upgrade to a new version of R on your computer, it's possible that everything will continue to work without any trouble, but it's also possible that you'll run into problems. The purpose of this article is to explain these problems, and how to fix them. Read more ...
When writing Shiny apps, it's fairly common to have a reactive expression or output that can only proceed under certain conditions. Read more ...
Where you define objects will determine where the objects are visible. There are three different levels of visibility that you'll want to be aware of when writing Shiny apps. Read more ...
In the past, users of Shiny applications would get disconnected from the server and see the browser window "gray out" if the network connection was interrupted, even if it was just briefly. There are now two ways that the client browser can reconnect to a session on the server -- it can reconnect to the existing session, or it can reconnect to a new session. Read more ...
With the release of Shiny 0.14, you now have the option to sanitize error messages. This can be important if there is information in the original error message that you don't want the user to see (usually because it may be sensitive information). Read more ...
This article will show you how to craft "validation errors," errors designed to lead your user through the UI of your Shiny app. Validation errors are user-friendly and, unlike the bold red error message, pleasing to the eye. Best of all, validation errors respond directly to your user's input. Read more ...
Since Shiny v0.10.1, we have added support for multi-byte characters in Shiny apps on Windows. This article is especially relevant for Windows users since Windows does not have a single consistent locale or native character encoding. Read more ...
Improve Testing
back to top
Automatically check that your app continues to work as expected.
A survey of the various types of tests available to help improve the reliability and stability of your Shiny apps. Read more ...
The shinytest package provides tools for creating and running automated tests on Shiny applications. Read more ...
Introduces the testServer() function which offer a framework for testing the relationships between reactives. Read more ...
Improve Modules
back to top
Create reusable pieces of Shiny apps with modules and namespaces.
As Shiny applications grow larger and more complicated, we use modules to manage the growing complexity of Shiny application code. Read more ...
While using modules already helps to manage an application's complexity, there are useful techniques you can emply to ensure a clear model for communication between modules themselves and with the overall application. Read more ...
Improve Measure usage
back to top
Understand the level of reach and usage of your apps.
You may want to track visitors to your Shiny application and analyze how they interact with it. This article will demonstrate techniques for implementing 3rd party tools that track and analyze usage metrics. Read more ...
This article will show you how to add Google Analytics to a Shiny app. Read more ...
Improve Performance and scalability
back to top
Learn how to identify and remove performance bottlenecks in your Shiny code.
Speed up and scale up your Shiny app with caching. Read more ...
Using cached plots can dramatically speed up your app when there are many users. Read more ...
The profvis package provides tools for helping you to understand how R spends its time. It provides a interactive graphical interface for visualizing data from Rprof, R’s built-in tool for collecting profiling data. Read more ...
Now that you know how to profile your Shiny app code to identify which parts of your code is slowing down your app, the next step is to increase the performance of your code and hence your app. Read more ...
Asynchronous programming is a powerful but advanced technique for increasing the scalability of your Shiny apps. On its own, async programming doesn't increase the performance or responsiveness for a single user of your app, but can improve responsiveness (dramatically, in some cases) when multiple users are active at the same time. Read more ...
Improve Tuning
back to top
Tune the performance of your apps.
As your applications get more complex, requiring more time to service a single request, and as more users interact with the application simultaneously, you may find that the user experience for your applications does not meet your expectations. Shinyapps.io lets you optimize the performance of your apps with several tuning parameters. Read more ...
This article contains links to support documents for scaling and tuning applications in Shiny Server Pro and RStudio Connect. Read more ...
Share Deployment
back to top
Run your app on a server.
Once you've written your Shiny app, you can make it available to anyone who has a web browser, using our Shiny Server software. You can either host the applications on your own server or let us host your Shiny applications for you. Read more ...
Shinyapps.io is a platform as a service (PaaS) for hosting Shiny web apps (applications). This article will show you how to create a shinyapps.io account and deploy your first application to the cloud. Read more ...
With shinyapps.io, you can limit access to your application by enabling authentication. To enable authentication in the administrative UI, select the application to modify and click on the Users tab. Read more ...
The shinyapps.io Professional plan offers customers the ability to host their Shiny applications using their own domains. This can be useful if you want to control the URL that is viewed by the end-user when you share your application with them. Read more ...
shinyapps.io expects your applications to be portable across servers. It uses this feature to maintain a smooth user experience. For example, shinyapps.io will scale up your application by adding more running instances, or shinyapps.io will keep your application available by starting your application on a server that has sufficient resources to host it. Both of these features will fail if your app is not portable. Read more ...
The general release of shinyapps.io introduced a new mechanism for authentication and authorization. This system replaced the previous rscrypt based approach to provide a more flexible and manageable flow. Read more ...
Shiny Server is a back end program that makes a big difference. It builds a web server specifically designed to host Shiny apps. With Shiny Server you can host your apps in a controlled environment, like inside your organization, so your Shiny app (and whatever data it needs) will never leave your control. Read more ...
This article describes how to configure deployed applications to use different sets of libraries. Read more ...
It is easy to create User Privileges in Shiny apps when you use Shiny Server Pro or RStudio Connect. Your app can recognize a user based on log-in information and deliver personalized content in response. Read more ...
Learn more about administrating RStudio Connect and Shiny Server Pro. Read more ...
Share Distribution
back to top
Share the code of your app with others.
Once you've written your Shiny app, you can distribute it for others to run on their own computers - they can download and run Shiny apps with a single R command. Read more ...
Shiny apps are a great way to build interactive data analysis tools, but they require a bit of set up to use. This article will show you how to write R functions that launch Shiny apps. Read more ...
Share Bookmarking
back to top
Bookmark the state of your application and get a URL which will restore the application with that state.
As of version 0.14, users can save the state of an application and get a URL which will restore the application with that state. There are two types of bookmarking -- encoding the state in a URL, and saving the state to the server. Read more ...
For applications that don't have a straightforward reactive flow -- where the state of the inputs at a given time doesn't fully determine the state of the outputs -- it may be necessary to use additional tools to save and restore the desired state. Read more ...
Shiny's bookmarking works with modules. As with Shiny applications, if the state of your module's outputs are fully determined by the state of the inputs at a given time, then no modifications are necessary. If bookmarking is enabled by the application, then it will work for the module. Read more ...