App 1: UI using NS once

From shiny::NS() documentation.

If id is missing, returns a function that expects an id string as its only argument and returns that id with the namespace prepended.

histogramUI <- function(id) {
  ns <- NS(id)
  tagList(
    selectInput(ns("var"), "Variable", choices = names(mtcars)),
    numericInput(ns("bins"), "bins", value = 10, min = 1),
    plotOutput(ns("hist"))
  )
}