Skip to content

Server Components (.server.x.py)

Sarthak Ghoshal edited this page Nov 8, 2025 · 2 revisions

Server Component Files (.server.x.py)

these are rendered on the server, then hydrated

from reactpy import component, html


def logic():
    return "server"


@component
def page(logic=logic()):
    return html.h1(f"Hello, from the {logic}!")

Syntax:

similar to regular files BUT you CANNOT use hooks you must include a logic() function, and put it as a param in the component

Clone this wiki locally