0

I am building a multipage shiny application - that is, the application consists of several (independent) main pages with buttons to go forward and (sometimes) backwards. As far as I can see - and in line with the general two possibilities to build a shiny app -, there are two main approaches

  1. Build the pages in the userinterface (ui.R), then hide and show each pages accordingly. This is the approach followed by @daattali in this demonstration app, using shinyjs to hide and show each page. I suppose there could also be ways to do this by using navbar(), navlist() or tabsetPanel(), if one can hide the navigation bar oder navigation list. This has the advantage of updating pages simply via updateTabsetPanel(), updateNavbarPage() or updateNavlistPabel(), rendering shinyjs unneccesary.
  2. Second approach is to build the pages on the serverside with renderUI() and limiting ui.R to a stub. This is the approach followed for example by TomW, limiting ui to renderUI() and doing everything else server side; and the approach treated in this discussion

So my question is:

What are the advantages and disadvantages of each approach respectively what are situations where you should or should not use each approach?

I will provide an answer as to what I know at the moment, but would be glad of corrections and additions.

Julian
  • 741
  • 8
  • 19

1 Answers1

0

Building Pages User-Side

Advantages

  • Ui only needs to be built once, saving network traffic and server load.
  • Better control of availability: UI is always built before the server, so all pages are availabe at initialisation time.
  • Inputs do not need to be reinitialised when page is displayed again.
  • Order (and thus eventually numbering, for example of CSS-classes) is obvious.

Disadvantages

  • If "same" inputs are to be displayed on several pages, two inputs have to be synchronised, instead of simply rebuilding the input using the old value.
  • Bloated ui.R, possibly separating ui and server logics;
  • Big Page user side, since all pages are built at once and only hidden from user`s view

Building Pages Server-Side

Advantages

Disadvantages

  • network traffic and server load; less control of availabily
  • Possibilites of styling elements per CSS which rely on internal counting of CSS classes are harder to achieve. One example is to color sliderInputs in different colors.

So I would say: If you have only few pages, you know the sequence beforehand or you want users to switch back and forth between the pages, build it user-side. If you have a huge number of pages, call pages only once or need to include dynamic input, build it server-side.

Julian
  • 741
  • 8
  • 19