React-logic – DI and signals – write react without hooks
Hey hackernews, this is a library I created to make react code more manageable, with less code. When working with react I hated how components became hundreds o
Stop layout shift in React UIs. Predict text height before render. No DOM measurement, no scrollHeight hacks, no reflow.
Pure-JS text layout at 0.03ms beats getBoundingClientRect reflow hacks for accordions.
Frontend developers, React engineers building animated UIs
@chenglou/pretext · Framer Motion layout tools · CSS container queries
The library wraps @chenglou/pretext, a pure-JS text layout engine that replicates the browser's line-breaking. algorithm using font metrics loaded once via the Font Metrics API. From there, computing height is arithmetic — no DOM, no getBoundingClientRect, no reflow. A prepare() call runs in ~0.03ms; a layout() call in under 0.01ms. Results are cached in a module-level LRU map so repeated calls for the same font/size pair are nearly free.
The main hooks are useTextLayout (height + line count for a block at a given width), useBubbleMetrics (finds the tightest width that preserves line count, which eliminates the dead space you get from CSS fit-content), and useStableList (pre-computes heights for a list of items before paint, useful for virtualized lists and masonry layouts). There's also a MeasuredText drop-in component with a debug overlay that draws predicted line boundaries over actual rendered text so you can see where predictions diverge.
The honest limitation: it only works with fonts you can load metrics for, so arbitrary system fonts or poorly-behaved variable fonts may drift. The isReady flag on every hook is false until font metrics load, so you need to gate renders on it when using web fonts. It also doesn't handle white-space: pre-wrap yet. Feedback welcome — especially if you've hit edge cases with font loading or non-Latin scripts.
GitHub: https://github.com/ahmadparizaad/pretext-studio-core — npm: @pretext-studio/core
Hey hackernews, this is a library I created to make react code more manageable, with less code. When working with react I hated how components became hundreds o
Black-box font reverse-engineering via pixel rendering beats reading font tables directly.
Stop hook enforcement beats trusting agents to self-verify their work.
Ten times faster than Ink with cell-level diffing and native terminal scrollback.
React bindings for emerging WebMCP spec, but it's experimental and agents can't use it yet without the extension.
12kb Markdown renderer with zero dependencies when react-markdown bundles 300kb+.