Skip to content

Latest commit

 

History

History

split-code

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Split app code across multiple files (when codebase is large)

When creating Shiny apps with a lot of code and a complex UI, it can sometimes get very messy and difficult to maintain your code when it's all in one file. What you can do instead is have one "main" UI and "main" server and split your UI and server code into multiple files. This can make your code much more manageable and easier to develop when it grows large. You can split the code however you want, but I usually like to split it logically: for example, if my app has 4 tabs then the UI for each tab would be in its own file and the server code for each tab would be in its own file. The example code here shows how to separate the code of an app with two tabs into 2 UI files and 2 server files (one for each tab

Update: Shiny now has the concept of modules, which is another recommended approach for handling large code bases. Modules are a bit more complex but also much more powerful. I've started using modules to tackle the problem of large codebases, and I highly suggest you do too!