For React, Vue, Solid, Svelte, Astro and markdown
Line breaks that know what you mean.
Put square brackets around the words that belong together. They wrap as one unit at every width, with no hard line breaks and no guesswork.
npm install wordhugFresh bread [delivered daily]Fresh bread delivered dailyTry it
Drag the edge. Watch the words.
Why it exists
It started with a broken sentence.
Many Vietnamese words are made of several syllables with spaces between them: ăn mặc, to dress; học sinh, student; Hà Nội. To a browser, every syllable is its own word, so a line can end in the middle of one.
A bad break doesn’t just look untidy. It can change what the sentence says. Writers and designers know where a line must not break; until now the only tool they had was a hard <br>.
Mẹo chọn đồ giúp bạn ăn
mặc đẹp hơn mỗi ngày
The idea
Say what belongs together, not where to break.
Before: a line break for one screen size
<h1>Mẹo chọn đồ giúp bạn<br />ăn mặc đẹp hơn mỗi ngày</h1>With wordhug: a group that holds at any size
<h1>Mẹo chọn đồ giúp bạn [ăn mặc] đẹp hơn mỗi ngày</h1>Content stays content
Brackets live in the copy, where writers work. Layout stays in CSS.
Right at every width
The text still wraps naturally on any screen, just never inside a group. Works with
text-wrap: balance.Clean to copy
No stray line breaks when someone copies the text. Groups are plain inline-block spans.
Use it anywhere
One rule, every framework.
No runtime dependencies. Each framework is an optional peer, and every adapter follows the same parsing rules.
import { WordHug } from "wordhug/react";
export function Hero() {
return (
<h1>
<WordHug>{"Fresh bread [delivered daily] to [your door]"}</WordHug>
</h1>
);
}No hooks, no “use client”: renders in Server Components too.
<script setup>
import { WordHug } from "wordhug/vue";
</script>
<template>
<h1><WordHug>Fresh bread [delivered daily] to [your door]</WordHug></h1>
</template>Text comes from the default slot, interpolations included.
import { WordHug } from "wordhug/solid";
<h1>
<WordHug>{"Fresh bread [delivered daily] to [your door]"}</WordHug>
</h1>;Re-renders when any prop changes. Solid 2.
<script>
import { WordHug } from "wordhug/svelte";
</script>
<h1><WordHug text="Fresh bread [delivered daily] to [your door]" /></h1>Ships as source and compiles with your build. Svelte 5.
---
import WordHug from "wordhug/astro";
---
<h1><WordHug text="Fresh bread [delivered daily] to [your door]" /></h1>Static HTML, no client JavaScript. This site uses it.
// astro.config.mjs, or any unified pipeline
import rehypeWordhug from "wordhug/rehype";
export default { markdown: { rehypePlugins: [rehypeWordhug] } };A rehype plugin: writers put brackets in markdown, groups come out in HTML.
import { wordhugHtml } from "wordhug";
wordhugHtml("Fish & [chips]");
// → 'Fish & <span style="display: inline-block">chips</span>'No framework. Text is escaped, so the result is safe for innerHTML.
Keep it together.
npm install wordhug