server_redirect: Do a server side redirection

View source: R/server-side.R

server_redirectR Documentation

Do a server side redirection

Description

Do a server side redirection

Usage

server_redirect(to, session = shiny::getDefaultReactiveDomain())

Arguments

to

the destination of the redirection: a path ("/page2") or an http(s) URL. Other schemes are rejected.

session

shiny session object, default is shiny::getDefaultReactiveDomain()

Value

Used for side effect

See Also

redirect() to answer an url with an HTTP redirection instead.

Examples

library(shiny)

# `server_redirect()` is called from a page server, so it needs a session:
page(
  href = "/login",
  ui = tagList(actionButton("go", "Take me home")),
  server = function(input, output, session) {
    observeEvent(input$go, {
      server_redirect("/")
    })
  }
)

brochure documentation built on Oct. 14, 2026, 5:08 p.m.