Access all plots in `output` in server Shiny

Let's say I have an app that looks like this:

library(shiny)
library(ggplot2)

ui <- fluidPage(
    plotOutput("plot1"),
    plotOutput("plot2")
    # mod_plots_ui("plots")
)

server <- function(input, output, session) {
    output$plot1 <- renderPlot({
        plot(mtcars$mpg, mtcars$cyl)
    })
    
    output$plot2 <- renderPlot({
        hist(mtcars$mpg)
    })
    
    # mod_plots_server("plots", output)
}

shinyApp(ui, server)

I want to pass output$plot1 and output$plot2 (basically the whole output list) as input to my module mod_plots_server to upload plots to some website. How can I do it? (Or, what is the best practice to do this?)

Can you try to save both plots in a reactiveValues and pass that to the module server?

plot1 <- reactiveVal( plot(mtcars$mpg, mtcars$cyl))

output$plot1 <- renderPlot(plot1())

mod_plots_server("plots", plot1)