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 wordhug
Read the docs

Try it

Drag the edge. Watch the words.

Without wordhug

With wordhug

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

“Outfit tips to help you eat” on the first line, where it should say “dress”.

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>
  1. Content stays content

    Brackets live in the copy, where writers work. Layout stays in CSS.

  2. Right at every width

    The text still wraps naturally on any screen, just never inside a group. Works with text-wrap: balance.

  3. 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.

Keep it together.

npm install wordhug
Read the docs