concrete/server/no-client-runtime
Server-rendered code uses no effect, state, event handler, network call or browser global.
Server-rendered code uses no effect, state, event handler, network call or browser global.
Graded by the lint stage of concrete check, in the lint venue. A violation reports this id and the file it failed at — see every rule and concrete check.
Reason
A section renders once, on a server, into HTML — there is no hydration of your section
and no second pass in which an effect could run or a handler could fire.
Server and client are separated by that boundary: state,
effects, refs, browser globals and on* handlers are simply dropped from the markup that
reaches a visitor, so code written as though they worked is code that silently does
nothing on every published page.
Fix
Interactivity is not banned, it is relocated. Put the interactive markup in a
"use client" module with a default export, render that component from the section, and
it hydrates as an island — where state, effects and handlers all work.
Before and after
import { Section, section, Slot, text } from "@homepages/concrete";
import { useState } from "react";
export const Faq = section(
{ key: "faq", label: "FAQ", slots: { answer: text.long({ label: "Answer" }) } },
({ slot }) => {
const [open, setOpen] = useState(false);
return (
<Section>
<button onClick={() => setOpen(!open)}>Details</button>
{open ? <Slot.Text slot={slot.answer} as="p" multiline /> : null}
</Section>
);
},
);import { Section, section, Slot, text } from "@homepages/concrete";
// The island, imported from its own `"use client"` module.
declare const Disclosure: (props: { label: string; children?: React.ReactNode }) => React.ReactNode;
export const Faq = section(
{ key: "faq", label: "FAQ", slots: { answer: text.long({ label: "Answer" }) } },
({ slot }) => (
<Section>
<Disclosure label="Details">
<Slot.Text slot={slot.answer} as="p" multiline />
</Disclosure>
</Section>
),
);