The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

shinyreact shinyreact hex logo

Lifecycle: experimental check-r

shinyreact lets you write the UI of a Shiny app as a React client you own, while the R server contains only reactive computation. It provides the bridge between the two and ships zero UI components itself. The same JavaScript bundle backs the Python package, so one React client works against an app.R or an app.py server. The full site covers all three.

Installation

install.packages("shinyreact")

Or install the development version from GitHub:

# install.packages("pak")
pak::pak("posit-dev/shinyreact/pkg-r")

Usage

page_react() discovers www/ui.js (and www/ui.css, if present) and serves them as the page. reactive_output() publishes any JSON-serializable value to the client’s useShinyOutputValue() hook:

library(shiny)
library(shinyreact)

server <- function(input, output, session) {
  output$greeting <- reactive_output({
    paste0("Hello, ", input$name, "!")
  })
}

shinyApp(page_react(), server)

The matching www/ui.js:

const { React, ReactDOM, useShinyInput, useShinyOutputValue } = window.shinyreact;
const h = React.createElement;

function App() {
  const [name, setName] = useShinyInput("name", "world");
  const greeting = useShinyOutputValue("greeting");
  return h(
    "div",
    null,
    h("input", { value: name, onChange: (e) => setName(e.target.value) }),
    h("p", null, greeting)
  );
}

ReactDOM.createRoot(document.body.appendChild(document.createElement("div"))).render(h(App));

Try a complete app without cloning:

shiny::runGitHub("posit-dev/shinyreact", subdir = "examples/01-hello")

Learn more

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.