Chapter 1 Introduction

1.1 What is Shiny?

1.2 What you will learn

If you’ve never used Shiny before, welcome!

The first part of the book, “Getting started”, is designed to get you up and running with Shiny as quickly as possible. This is pretty quick, because Shiny is carefully designed to let you get started writing apps as quickly as possible. We’ll teach you a few recipes to follow that let you turn your existing R code into basic apps by wrapping key bits of code in reactive({...}) or renderXXX({...}).

In “Shiny in Action”, you’ll learn a bunch of common patterns for building Shiny apps.

Then in “Mastering UI”, you’ll dive further into the many options you have for the front-end of your app.

In “Mastering reactivity”, you’ll go deep into the theory and practice of reactive programming, the programming paradigm that underlies Shiny. If you’re an existing Shiny user, you’ll get the most value out of this chapter as it will give you a solid theoretical underpinning that will allow you to create new tools specifically tailored for your problems.

The biggest drawback of reactive programming is that it’s a fundamentally new programming paradigm. Even experienced R users can have trouble getting their heads around reactive programming, and those with deep experience in software engineering may feel uncomfortable with so much “magic”. But once you’ve formed an accurate mental model, you’ll see that there’s nothing up Shiny’s sleeves: the magic comes from simple concepts combined in consistent ways.

Finally, in “Taming Shiny” we’ll finish up a survey of useful techniques for making your Shiny apps work well in production. You’ll learn how to measure and improve performance, debug problems when they go wrong, and manage your app’s dependencies.

1.3 What you won’t learn

The focus of this book is making effective Shiny apps and understanding the underlying theory of reactivity. I’ll do my best to show off best practices for data science, R programming, and software engineering at the same time as well, but you’ll need other references to master these other important components.

1.4 Prerequisites

The first thing you’ll need to do is install the software you’ll need, if you don’t have it already:


If you don’t have R installed already, you may be reading the wrong book; you need to be proficient with R if you want to write Shiny apps. If you’d like to learn how to use R, I’d recommend my R for Data Science book which is designed to get you up and running with R with minimum of fuss.


RStudio is a free and open source integrated development environment (IDE) for R: a single program that includes a code editor, R console, graphics device, and many features for working productively with R.

While you can write and use Shiny apps with any R environment (including R GUI and ESS), RStudio has some nice features specifically for authoring, debugging, and deploying Shiny apps. We recommend giving it a try, but it’s not required to be successful with Shiny or with this book.

You can download RStudio Desktop at


Shiny is an R package; you install it the same way you install any R package. From the R console:

Other R packages

This book is heavy on code, and we will often use other R packages in our examples. You can install them all now by running this code:

TODO: Update this list before final draft; see DESCRIPTION for the definitive list.

1.5 Cheat sheet

You may find it helpful to print a copy of our Shiny “cheat sheet”, a reference card for many of the most important concepts and functions in Shiny. It won’t all make sense to you yet, but as you work through the chapters you’ll find it more and more helpful to refresh your memory.

1.6 Acknowledgements

This book was written in bookdown inside RStudio. The website is hosted with netlify, and automatically updated after every commit by travis-ci. The complete source is available from GitHub.