Alternatives when distributing Shiny app as a package

Hi all,

As the title says, I have a few questions about the differences between the methods of distributing a Shiny app as a package. For context: I have been developing an app with the two main ui and server files, and a few additional files with specialised functions, but no modules. I started to convert it into a package, placing all R files in the R folder of the package and using a run_app function that calls the runApp(ui,server) function. The aim of the package, at least for now, is to have the app run locally, e.g. from RStudio, but eventually also deployed in a Shiny server.

I have seen one way of deploying it, which is similar to the description at the end of this article. But, from what I understand (also looking at the golem package), there are two ways of structuring the app as a package: either through the shinyApp(appdir) function (placing ui and server files in inst/myapp folder, all other R files in the R folder) or with the runApp(ui, server) function (ie. all files in R folder).

My question is if one of these methods is better than the other (or if there is a correct way?) and if they also significantly change how I develop the app and write code (e.g. when importing a package))? For instance, are there additional steps required to do certain things when using one method or the other? (as a note, I have so far failed to include markdown files server-side using the second method).


... shinyApp is just a function that makes a shiny app object. This is the sort of thing that runApp can then run... although runApp can do more also.

  app <- shinyApp(
    ui = bootstrapPage(
      numericInput('n', 'Number of obs', 100),
    server = function(input, output) {
      output$plot <- renderPlot({ hist(runif(input$n)) })

note that in this example. theres no folders at all...

You have a lot of flexibility, do what please you. Also feel free to change your mind about what pleases you. Thats my advice.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.