R Shiny Template v2.0
TLDR; https://github.com/samuelbharti/RShiny_template |
Building Scalable, Reproducible R Shiny Apps with Modern Templates
Version 2.0 adds reproducibility, container support, and citation metadata to the original R Shiny template. The goal is to make it easier to start new apps with a structure that stays clean as the project grows.
What’s New in v2.0
The template now includes:
- renv for reproducibility - Lock package versions and restore the same R environment on another machine.
- Docker support - Build and run the app in a container for more consistent deployment.
- Zenodo citation metadata - Include
CITATION.cffandCITATION.mdso the project is easier to cite. - Development helper - Use
dev/init-renv.Rto initializerenvand createrenv.lock.
Why Use a Modern Shiny Template?
If you’ve ever started a Shiny app from scratch, you know how quickly the code can become hard to manage. A template gives you a clean starting point and keeps the app organized into separate pieces as it grows.
This version is built to be:
- Reproducible -
renvlocks package versions. - Containerized - Docker keeps development and deployment closer together.
- Maintainable - Modules and page-level UI files keep the codebase tidy.
- Citable - Zenodo metadata makes the project easier to reference in research.
The Structure of the Template
.
├── global.R
├── ui.R
├── server.R
├── R/
├── modules/
├── userInterface/
├── data/
├── dev/
│ └── init-renv.R
├── www/
├── docs/
├── Dockerfile
├── renv.lock
├── CITATION.cff
├── CITATION.md
├── .gitattributes
├── .dockerignore
└── .Rbuildignore
Key Components
1. Global separation: ui.R, server.R, and global.R
Instead of putting everything into one app.R file, the template separates the app into smaller files. That makes the project easier to read, debug, and extend.
2. Modularization: the modules/ folder
Each module keeps its UI and server logic together, which makes pieces of the app reusable across projects.
3. Automation: the R/ folder
Files in R/ are sourced automatically, which is a simple place for utility functions and shared helpers.
4. Development space: the dev/ folder
The dev/init-renv.R script helps initialize renv, install recommended packages, and create renv.lock for a new project.
5. User interface files: the userInterface/ folder
Split page-level UI into separate files so the main ui.R file stays manageable.
6. Static assets: the www/ folder
Use www/ for CSS, JavaScript, and images. Shiny serves these files automatically.
7. Data management: the data/ folder
Keep datasets separate from code so the app stays easier to maintain.
8. Reproducibility: renv.lock
When renv.lock is present, other users can restore the same package versions with renv::restore().
9. Docker support
The Dockerfile is set up to work with renv, so the app can be built and run consistently in a container.
10. Citation metadata
The repository includes CITATION.cff and CITATION.md, and the Zenodo badge links to the release DOI for version 2.0.
How to Use the Template
- Click Use this template on the repository page.
- Clone your new repo.
- Run
source("dev/init-renv.R")to initializerenv. - Add UI files to
userInterface/, modules tomodules/, helpers toR/, and data todata/. - Update
CITATION.cffandCITATION.mdif you publish a Zenodo release. - Build the app with Docker when you are ready to deploy.
How to Cite This Template
If you use this template or a derivative in your research or project, please cite it:
APA:
Bharti, S. (2026). RShiny Template (version 2.0) [Software]. Zenodo.
https://doi.org/10.5281/zenodo.19968600
BibTeX:
@software{rshiny_template_2026,
author = {Bharti, Samuel},
title = {RShiny Template},
version = {2.0},
date = {2026-05-02},
doi = {10.5281/zenodo.19968600},
url = {https://doi.org/10.5281/zenodo.19968600}
}By using this template, I hope developing Shiny apps becomes a smoother process and that your work is easier to reproduce and cite.
Happy coding!
Written by me, edited with the help of AI agents. Please feel free to reach out if you spot any typos or have corrections!