Best Pratice of Shiny Apps


Hi all,

We have 20+ applications for different clients hosted on Most of the application are loading the same R codes.

If we find a bug on part of the code which are commonly used across all the apps, we will need to go to 20 apps to change the code on server.R and republish it. Is any way we can API to the R codes somewhere else so once the codes are updated, all applications will link to the new R codes without re-publishing all of them.

Thank you,


You could consider moving the common R code to a package. It needn’t be on CRAN and could even be stored in a private repo on GitHub, so there’s no public IP. When the shiny app is deployed, it can reinstall the package. I’ve done this on and it works a treat.


Depending on your specific case, you could try to make an API with your code using for example plumber :package:
Then you can deploy the API and call it from your apps.

Otherwise, I think the package way suggested in this conversation is the way to go to maintain R code used widely. However, you’ll still need to update your twenty apps to use this package.


To avoid having to redeploy to when you want to change something in your code, you’ll have to setup each app to pull in code from an outside source (not hosted in the app directory on the server).

As @PirateGrunt and @cderv mentioned, you can achieve this through private packages on github or APIs with plumber and have your app call them each time they run.

If you’re unsure about either of these options, another would be to host a .R file on dropbox or googledrive with all the functions and modules your apps require. You can then download the file into your app’s environment using the rdrop2 or googledrive package with a cached auth token, then source it in your server and ui files.

Any changes you make to the code in your file hosted in the cloud will then be ported into your shinyapps without having to redeploy the whole thing to the server.