Switch branches/tags
Nothing to show
Find file History
Latest commit 9ff9a9d Mar 3, 2018
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
server add split-code app Jun 11, 2016
ui add split-code app Jun 11, 2016
README.md Update README.md Mar 3, 2018
app.R add split-code app Jun 11, 2016

README.md

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!