Articles

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 basic parts of a Shiny app
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 ...
How to build a Shiny app
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 ...
How to launch a Shiny app
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.
How to get help
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 sheet
The Shiny cheat sheet is a quick reference guide for building Shiny apps. Read more ...
Build Standalone apps
back to top
Enhance your understanding of building individual apps.
App formats and launching 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 ...
Two-file Shiny apps
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.
Introduction to R Markdown
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 ...
Introduction to interactive documents
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 ...
R Markdown integration in the RStudio IDE
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
The R Markdown cheat sheet is a quick reference guide for writing reports with R Markdown. Read more ...
Setting Output args via Render functions
This article discusses how to set output directly from the render function when working with just snippets of Shiny code. Read more ...
Generating downloadable reports
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.
Dashboards
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
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 ...
Designing Gadget UI
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.
Reactivity - An overview
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 ...
Stop reactions with isolate()
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 ...
Execution scheduling
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 ...
How to understand reactivity in R
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 ...
Learn about your user with session$clientData
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.
Database basics - dplyr and DBI
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 injection prevention
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 ...
Using the pool package (basics)
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 ...
Using the pool package (advanced)
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 ...
Using dplyr and pool to query a database
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 ...
Persistent data storage in Shiny apps
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.
Application layout guide
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 ...
Display modes
Shiny can display your apps in two different ways -- normal mode and showcase mode. Read more ...
Tabsets
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 ...
Customize your UI with HTML
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 ...
Build your entire UI with HTML
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 ...
Build a dynamic UI that reacts to user input
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 ...
HTML Templates
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 HTML Tags Glossary
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 ...
Progress indicators
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 ...
Modal dialogs
As of version 0.14, Shiny has built-in support for displaying modal dialogs. Read more ...
Notifications
As of version 0.14, Shiny can display notifications on the client browser by using the showNotification function. Read more ...
Themes
You can also easily alter the overall appearance of your Shiny application using the shinythemes package, which contains CSS themes ready to use with Shiny. Read more ...
Render images in a Shiny app
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 ...
Displaying and customizing static tables
This article describes how to use the improved renderTable Shiny function. Read more ...
How to use DataTables in a Shiny App
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 ...
Using Action Buttons
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 ...
Using sliders
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 ...
Help users download data from your app
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 ...
Help users upload files to your app
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 ...
Using selectize input
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!).
Interactive plots
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 ...
Selecting rows of data
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 ...
Interactive plots - advanced
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
htmlwidgets is framework for embedding JavaScript visualizations into R. Read more ...
JavaScript actions packaged for Shiny apps
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 ...
How to build a JavaScript based widget
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 ...
How to add functionality to JavaScript widgets
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 ...
How to send messages from the browser to the server and back using Shiny
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 ...
How to develop an interactive, dynamic help system for your app with introJS
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 ...
How to create custom input bindings
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 ...
Putting everything together to create an interactive dashboard
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.
Style your apps with CSS
You can give your Shiny app a special look with cascading style sheets (CSS). Since the Shiny app user-interface (UI) is an HTML document, you can use CSS to control how you want your Shiny app to look. Read more ...
Build custom input objects
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 ...
Build custom output objects
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 ...
Add Google Analytics to a Shiny app
This article will show you how to add Google Analytics code to a Shiny app. You will need to know a little about JavaScript and jQuery to use this method (which we will not teach here). Read more ...
JavaScript Events in Shiny
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
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 ...
Upgrading to a new version of R
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 ...
Handling missing inputs with req(...)
When writing Shiny apps, it's fairly common to have a reactive expression or output that can only proceed under certain conditions. Read more ...
Scoping rules for Shiny apps
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 ...
Reconnecting to Shiny apps
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 ...
Sanitizing error messages
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 ...
Write error messages for your UI with validate
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 ...
Unicode characters in Shiny apps
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.
shinytest
The shinytest package provides tools for creating and running automated tests on Shiny applications. Read more ...
Improve Modules
back to top
Create reusable pieces of Shiny apps with modules and namespaces.
Modularizing Shiny app code
As Shiny applications grow larger and more complicated, app authors frequently ask us for techniques, patterns, and recommendations for managing the growing complexity of Shiny application code. Read more ...
Improve Measure usage
back to top
Understand the level of reach and usage of your apps.
Shiny App Usage Tracking
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 ...
Add Google Analytics to a Shiny app
This article will show you how to add Google Analytics code to a Shiny app. You will need to know a little about JavaScript and jQuery to use this method (which we will not teach here). Read more ...
Improve Performance
back to top
Increase the performance of your apps.
Performance
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 ...
Improve Profiling
back to top
Understand how R spends its time in your app and use this information to enhance the performance of your app.
Profiling your Shiny app
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 ...
Improve Tuning
back to top
Tune the performance of your apps.
Scaling and Performance Tuning with shinyapps.io
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 ...
Scaling and Performance Tuning with Shiny Server Pro and RStudio Connect
This article contains links to support documents for scaling and tuning applications in Shiny Server Pro and RStudio Connect. Read more ...