@nifrajs/web-vanilla
v5.18.1
Published
Zero-framework render adapter for @nifrajs/web - auto-escaping tagged-template HTML, ~0 KB client JS, interactivity via @nifrajs/web/islands.
Maintainers
Readme
@nifrajs/web-vanilla
Zero-framework render adapter for @nifrajs/web - auto-escaping tagged-template HTML, ~0 KB client JS, interactivity via @nifrajs/web/islands.
Part of the nifra full-stack TypeScript framework - one core, five UI libraries, every runtime. Scaffold a new app with bun create nifra.
The AI-safe lane
Vanilla is the render adapter an agent gets right on the first try. It ships no framework runtime, so there is no hydration, no reactivity, and none of the failure modes (stale closures, hydration mismatch, what-re-runs-when) that trip up generated code. You get true SSR plus every server feature - loaders, actions, ISR/SSG, streaming, head management - unchanged from @nifrajs/web; those live in the core, not the view layer.
Interactivity is added with islands, not hydration: small imperative DOM enhancers over server-rendered elements. defineIsland types the props, createIslandBus coordinates islands over a typed channel, and every enhancer returns its cleanup - the one rule nifra check enforces (NF-C020). See the islands cookbook for the counter, cart-badge, and filter patterns, or run nifra scaffold on a vanilla route for the golden stub.
To refresh one region from a link or GET form without a full reload, render it with slot(name, content) inside a data-swap-slot="<name>" element and mark the link or form data-swap="replace:<name>" or "append:<name>"; the page then answers a swap request with that slot alone, and enableSwap from @nifrajs/web/islands/swap puts it in place. POST forms submit natively, and a swapped slot runs under the current page's Content-Security-Policy. See Refresh part of the page.
Escaping
html writes each interpolated value for the place it lands, read from the template's own text:
- In text and in a quoted attribute value, it is HTML-escaped.
- An unquoted attribute value (
class=${name}) is quoted for you, so a space in the value cannot start another attribute. - A
javascript:orvbscript:URL that begins anhref,src,actionor other URL attribute is written asabout:invalid. So is adata:URL that begins thesrc(orhref) of a<script>, which runs; adata:image, download, frame or object URL is kept. - No escaping makes a string safe as a tag name, inside
<script>or<style>, or in anon*handler orsrcdocvalue, so a string or nested template throws there. An attribute name takes only a plain name with no value (<input ${checked ? "checked" : ""}>), or a suffix afterdata-oraria-. Numbers and booleans fill any of these, andraw()is the explicit opt-out for trusted text.
Need a stateful app UI with reactive components? That is what the five framework adapters are for - reach for @nifrajs/web-preact or @nifrajs/web-solid when you want a small reactive runtime.
Install
bun add @nifrajs/web-vanillaDocs
- Reference: https://nifra.dev/docs
- AI-readable: https://nifra.dev/llms.txt
MIT
For AI agents
Start with LLM.md - this package's contract card (the exports you call + its footguns),
one cheap read instead of the whole corpus. For the wider framework: the repo's
AGENTS.md is the copy-paste quick reference, and
llms-full.txt is the full machine-readable corpus. Run nifra check as the
done-gate, or nifra mcp to give the agent live project tools.
