shinyreact lets you write the UI of a Shiny for Python app as a React client you own, while the Python server contains only reactive computation. It provides the bridge between the two and ships zero UI components itself. The same JavaScript bundle backs the R package, so one React client works against an app.py or an app.R server. The full site covers all three.
pip install shinyreactOr install the development version from GitHub:
pip install "git+https://github.com/posit-dev/shinyreact.git"set_react_page() discovers www/ui.js (and www/ui.css, if present) next to the app file and serves them as the page. @reactive_output publishes any JSON-serializable value to the client's useShinyOutputValue() hook:
from shiny.express import input
from shinyreact import reactive_output, set_react_page
set_react_page()
@reactive_output
def greeting():
return f"Hello, {input.name()}!"In Core mode, page_react() is the ui argument instead:
from shiny import App
from shinyreact import page_react, reactive_output
def server(input, output, session):
@reactive_output
def greeting():
return f"Hello, {input.name()}!"
app = App(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:
git clone https://github.com/posit-dev/shinyreact
shiny run shinyreact/examples/01-hello/app.py- Get started walks through the
ui.tsxpattern: inputs, outputs, messages, and embedding traditional Shiny renderers. - TSX files and JavaScript build tools explains
.tsx, JSX, TypeScript, and whatnpm run builddoes. - Client hooks lists everything at
window.shinyreact. - Testing covers shiny's
local_serverpytest fixture for driving a server with no browser, andWireTapfor wire payloads in Playwright tests. - Agent Skills explains the skills that ship with the package for coding agents.
- The examples catalog lists runnable apps from no-build to Vite + HMR.