Introduction
Using R package development practices when building Shiny applications saves time and makes collaboration easier. Packages give your code clear structure and make it simple for others to install, use, and understand your work. This book teaches you how to combine Shiny and R package development into a cohesive workflow.
Why this book?
R Packages, 2ed is the authoritative guide to package development, but it doesn’t cover Shiny.
Mastering Shiny teaches application design and reactivity, but package development remains optional and brief. If you’ve read one and wanted the other, you’ve hit a gap this book fills.
This book combines both approaches through worked examples of a complete Shiny app-package: structure, testing, documentation, deployment. Most developers have existing Shiny applications they want to turn into packages, so we’ll organize chapters around that journey rather than building from scratch.
Other resources
The Shiny community has published other excellent resources.
Engineering Production-Grade Shiny Apps introduces the golem framework for standardized app development.
Outstanding User Interfaces with Shiny addresses UI customization with HTML, CSS, and JavaScript. We’ll cover these frameworks in the later chapters if they fit your needs.
Why packages for Shiny?
Do future you a favor.
Standardizing your projects saves setup time and ramp-up across applications. Using an R package structure gives you access to IDE tools (RStudio and Positron) for testing, documentation, and installation. A package is a boundary: it forces clarity about what’s internal and what you expose to users.
Assume someone else will read your code.
R packages provide a standard interface for sharing code. When others (or future you) encounter your Shiny app, a package makes it obvious where to find what, how to install it, and how to run it. No guessing about file paths or setup steps.
How to read this book
The chapters roughly follow the steps of package development, applied to an existing Shiny application. Each topic can work on its own, but together they form a complete workflow.
The first two sections cover the stable fundamentals: the “whole game” of building an app-package, Shiny structure, package basics, and development tools. These topics won’t change anytime soon.
The remaining sections are opinionated approaches to debugging, testing, and deployment. Many practices come from R Packages, 2ed and the Shiny community, but there are always multiple ways forward.
Development environments
The chapters demonstrate RStudio and Positron (Posit’s new IDE for multiple languages). Most workflows are the same in both—I’ll use icons to flag differences.
Package development outside an IDE (VS Code, command line, etc.) works the same way. You’ll call the same functions (roxygen2::roxygenize(), devtools::load_all(), devtools::install()), just without the point-and-click shortcuts.
Acknowledgments
This book came from conversations with Shiny developers new to packages, package authors learning Shiny, and new R users building robust applications. I’m grateful to:
- Henry Bernreuter & Elizabeth Marshallsay for the initial discussions that created the outline for this book
- Andrew Bates for being an exemplary developer and professional, quietly building outstanding UIs, applications, and packages
- Eric Simms for asking so many great questions, reviewing chapters, and giving phenomenal feedback
- Eric Nantz1 for his R podcast, Shiny developer series, workshops, and everything else he does for the Shiny community
- Philip Bowsher for everything he does for the R/Pharma conference and community
- Ted Laderas for his excellent gRadual intRoduction to Shiny course and insightful blog posts
- Jennifer Bryan and Hadley Wickham for their posit::conf(23) package development masterclass workshop.
- Maya Gans for having multiple conversations and Shiny modules and package dependencies
- Leon Samson for his feedback on the testing chapters





