0Pricing
R Academy · Lesson

Deploying Shiny Apps

Publish apps to shinyapps.io, Shiny Server, and Dockerized environments.

Deployment Options Overview

Shiny apps can be deployed on several platforms depending on budget, traffic expectations, and control requirements:

  • shinyapps.io: Managed cloud hosting by Posit — easiest, free tier available.
  • Shiny Server (open source): Self-hosted on Linux, free.
  • Posit Connect: Commercial, enterprise-grade, supports R Markdown and Plumber too.
  • Docker + rocker/shiny: Maximum portability and control.
# Summary of deployment options and their trade-offs:
# shinyapps.io: managed, auto-scaling, per-instance pricing
# Shiny Server: self-hosted, unlimited users, needs sysadmin
# Posit Connect: enterprise SSO, scheduling, REST APIs
# Docker: any cloud provider, reproducible environments

cat('Choose based on: scale, budget, infra control needs')

app.R Structure for Deployment

A deployable Shiny app must have either a single app.R file (containing both ui and server) or two files ui.R and server.R. All package dependencies must be declared with library() at the top. Data files must be in the same directory or accessible relative to the app.

# Minimal app.R for deployment
library(shiny)
library(ggplot2)
library(dplyr)

# Load data relative to app directory
data <- readRDS('data/processed_data.rds')

ui <- fluidPage(
  titlePanel('My Deployed App'),
  sidebarLayout(
    sidebarPanel(selectInput('var', 'Variable:', choices = names(data))),
    mainPanel(plotOutput('main_plot'))
  )
)

server <- function(input, output, session) {
  output$main_plot <- renderPlot({
    ggplot(data, aes_string(x = input$var)) + geom_histogram()
  })
}

shinyApp(ui, server)

All lessons in this course

  1. Reactive Programming Deep Dive
  2. Shiny Modules for Code Reuse
  3. Dynamic UI with renderUI and insertUI
  4. Deploying Shiny Apps
← Back to R Academy