posit-dev / r-shinylive

https://posit-dev.github.io/r-shinylive/
Other
151 stars 16 forks source link

Exporting interactive rmarkdown notebooks as Shinylive applications #47

Open luukvdmeer opened 7 months ago

luukvdmeer commented 7 months ago

By adding the runtime: shiny header you can build Shiny apps with RMarkdown documents: https://rmarkdown.rstudio.com/articles_interactive.html

I am wondering if its possible to also export such documents as Shinylive applications. When simply running shinylive::export("myapp", "site") with the myapp directory containing only an .Rmd file with interactive elements, it currently fails since there is neither an app.R nor server.R file present:

Error in shinylive::export("myapp", "site") : 
  Directory myapp does not contain an app.R or server.R file.

In the documentation of the interactive documents linked above it is mentioned that a server.R file is created when running the interactive notebook:

When you run an interactive document, rmarkdown extracts the code in your code chunks and places them into a pseudo server.R file. R Markdown uses the html output of the markdown file as an index.html file to place the reactive elements into.

However, I can't find the location where that file is stored, neither do I know if a "pseudo server.R file" is enough for shinylive.

schloerke commented 7 months ago

There are no current plans to support Rmarkdown for shinylive. You can use a quarto document with a shinylive cell, but not a server: shiny document.

Example link to quarto document: https://github.com/posit-dev/r-shinylive/blob/52ac800b95961803e35971cef445cd9d26db6239/local/quarto/shinylive.qmd

schloerke commented 7 months ago

It would be nice to have a server: shinylive (or similar) to have the document be able to be statically exported.