front.js

The secure-by-default, islands-first micro-framework

Three primitives: val, run, calc.
Zero build step. No magic. Just fine-grained reactivity for server-rendered HTML.

The Engine

front.js is built on three tiny, powerful primitives.

val(initial)

Fine-grained reactive state. Holds a value and notifies subscribers when it changes.

const count = val(0);

run(fn)

Auto-executing side effects. Automatically tracks dependencies and re-runs when they change.

run(() => console.log(count()));

calc(fn)

Derived state. Computes a value based on other values and caches the result.

const double = calc(() => count() * 2);

See It In Action

A real interactive island. No build step required.

How to Get Started

Two steps: Render HTML, then Hydrate with JavaScript.

1. Server (HTML)

Mark interactive areas with data-island.

<div
  data-island
  data-component="Counter"
  data-props='{"start": 10}'
></div>

<!-- Load front.js -->
<script type="module" src="/front.js"></script>

2. Client (JavaScript)

Define components using val, run, and html.

import { html, val, register, hydrate } from 'front-js';

function Counter(props) {
  // 1. Define State
  const count = val(props.start || 0);

  // 2. Return Render Function
  return () => html`
    <button onclick=${() => count(count() - 1)}>-</button>
    <span>${count()}</span>
    <button onclick=${() => count(count() + 1)}>+</button>
  `;
}

register('Counter', Counter);
hydrate();

Why use front.js?

Secure by Default

JSON-only data flow. No function serialization. No server closures crossing trust boundaries.

Zero Build Step

Write HTML and JavaScript. That's it. No bundlers, no transpilers, no configuration.

Tiny Runtime

Less than 5KB gzipped. Hard limit enforced in CI. Every byte counts.