Functional HTML — overreacted
13 hours ago
- This article reimagines HTML as a functional, programmable language by introducing custom tags via JavaScript functions that run on the server during serialization.
- Objects can be passed as first-class values to tags, and the primary output format is a JSON tree instead of traditional HTML, allowing richer data representation.
- Async server tags are supported with await, making data fetching part of the HTML structure.
- Client References (via 'use client' directive) enable sending code to the client, representing a first-class script tag.
- Server References (via 'use server' directive) allow clients to call server functions, acting as a first-class fetch API.
- Client Tags are server-encountered references that defer execution to the client, enabling full-stack components.
- Full-Stack Tags compose server and client tags, creating components that span both environments with encapsulated logic.
- Streaming is supported with placeholders for intentional loading states, avoiding page jumps.
- The JSON output format facilitates efficient caching by separating data from code, enabling cacheable partials with dynamic holes.
- The article concludes that this design effectively reinvents React Server Components as a functional, composable version of HTML.