How to put your R Shiny App on the Web using Heroku

Steve Condylios
3 min readJun 5, 2020

There are numerous ways of getting your R Shiny app on to the web. Some are expensive, others are tedious, and most are finicky. Heroku is neither. Here’s a guide to deploying your R Shiny app to the web using Heroku.

Heroku — what is it?

Heroku allows you to think far less about DevOps, letting you focus on building awesome apps.

With Heroku, you don’t have to manually provision infrastructure, relieving you of things like: starting EC2s from images, configuring security groups, setting port ranges, shelling in, installing dependencies, configuring a database, load balancing, scheduling, and any other configurations required to run your app 😅.

Heroku is mostly declarative meaning we tell it what we’re after, rather than having to think carefully about how to achieve each deployment step — Heroku takes care of this for us.

A simple example

Here is a very simple R Shiny app — let’s take a quick look:

Here’s server.R

# Define server logic required to draw a histogram ----
server <- function(input, output) {

# Histogram of the Old Faithful Geyser Data ----
# with requested number of bins
# This expression that generates a histogram is wrapped in a call
# to renderPlot to indicate that:
#
# 1. It is "reactive" and therefore should be automatically
# re-executed when inputs (input$bins) change
# 2. Its output type is a plot
output$distPlot <- renderPlot({

x <- faithful$waiting
bins <- seq(min(x), max(x), length.out = input$bins + 1)

hist(x, breaks = bins, col = "#75AADB", border = "white",
xlab = "Waiting time to next eruption (in mins)",
main = "Histogram of waiting times")

})

}

And here’s ui.R

library(shiny)

# Define UI for app that draws a histogram ----
ui <- fluidPage(

# App title ----
titlePanel("Hello Shiny!"),

# Sidebar layout with input and output definitions ----
sidebarLayout(

# Sidebar panel for inputs ----
sidebarPanel(

# Input: Slider for the number of bins ----
sliderInput(inputId = "bins",
label = "Number of bins:",
min = 1