kabr
kabr

Reputation: 1339

How to create a Shiny interactive .qmd document within a Quarto website?

I am building a Quarto website (https://quarto.org/docs/websites/) that should have some pages that work interactively with Shiny.

Assume this mini interactive file which should be named mini-app.qmd:

---
title: "Old Faithful"
format: html
server: shiny
---

```{r}
sliderInput("bins", "Number of bins:", 
            min = 1, max = 50, value = 30)
plotOutput("distPlot")
```

```{r}
#| context: server
output$distPlot <- renderPlot({
  x <- faithful[, 2]  # Old Faithful Geyser data
  bins <- seq(min(x), max(x), length.out = input$bins + 1)
  hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
```

This works as a common .qmd file, rendering, preview, everythings great.

But as soon as this file mini-app.qmd is part of a Quarto created with quarto create-project mysite --type website this interactive component isn't working anymore.

The error message:

Error in shiny_prerendered_html(input_rmd, render_args) : 
Prerendered HTML file not found at /Users/.../quarto-website/mini-app.html
Calls: .main ... <Anonymous> -> shiny_prerendered_app -> shiny_prerendered_html
Execution halted

How can I build a Quarto website that has some pages that are interactive with Shiny? What do I miss?

Upvotes: 3

Views: 1977

Answers (1)

kabr
kabr

Reputation: 1339

Short answer: not possible, because quarto website is static, Shiny is not.

Long answer: https://github.com/quarto-dev/quarto-cli/discussions/1561

Upvotes: 5

Related Questions