The render_gt() function

Here is a Shiny app (contained within a single file) that (1) prepares a gt table, (2) sets up the ui with gt_output(), and (3) sets up the server with a render_gt() that uses the gt_tbl object as the input expression.

library(shiny)

gt_tbl <-
  gtcars |>
  gt() |>
  fmt_currency(columns = msrp, decimals = 0) |>
  cols_hide(columns = -c(mfr, model, year, mpg_c, msrp)) |>
  cols_label_with(columns = everything(), fn = toupper) |>
  data_color(columns = msrp, method = "numeric", palette = "viridis") |>
  sub_missing() |>
  opt_interactive(use_compact_mode = TRUE)

ui <- fluidPage(
  gt_output(outputId = "table")
)

server <- function(input, output, session) {
  output$table <- render_gt(expr = gt_tbl)
}

shinyApp(ui = ui, server = server)

Listening on http://127.0.0.1:6178