R Shiny Template v2.0

templates
R
shiny
renv
docker
A reproducible and container-ready R Shiny template with renv, Docker, and Zenodo citation support.
Author

Samuel Bharti

Published

May 2, 2026

TLDR; https://github.com/samuelbharti/RShiny_template | DOI

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:

  1. renv for reproducibility - Lock package versions and restore the same R environment on another machine.
  2. Docker support - Build and run the app in a container for more consistent deployment.
  3. Zenodo citation metadata - Include CITATION.cff and CITATION.md so the project is easier to cite.
  4. Development helper - Use dev/init-renv.R to initialize renv and create renv.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:

  1. Reproducible - renv locks package versions.
  2. Containerized - Docker keeps development and deployment closer together.
  3. Maintainable - Modules and page-level UI files keep the codebase tidy.
  4. 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

  1. Click Use this template on the repository page.
  2. Clone your new repo.
  3. Run source("dev/init-renv.R") to initialize renv.
  4. Add UI files to userInterface/, modules to modules/, helpers to R/, and data to data/.
  5. Update CITATION.cff and CITATION.md if you publish a Zenodo release.
  6. 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!