Thanks to visit codestin.com
Credit goes to github.com

Skip to content

kfly8/barefootjs

Repository files navigation

BarefootJS

Reactive JSX for any backend
Generates Marked Templates + Client JS from Signal-based JSX


Quick Start

STEP 1. Write Signal-based reactive JSX

"use client"

import { createSignal } from '@barefootjs/dom'

export function Counter() {
  const [count, setCount] = createSignal(0)

  return (
    <>
      <p class="counter">{count()}</p>
      <button onClick={() => setCount(n => n + 1)}>+1</button>
      <button onClick={() => setCount(n => n - 1)}>-1</button>
      <button onClick={() => setCount(0)}>Reset</button>
    </>
  )
}

STEP 2. Compile to Marked Template + Client JS

npx barefootjs compile Counter.tsx

Output:

  • Counter.tsx - Marked Template (server-side, with data-bf hydration markers)
  • Counter.client.js - Client JS (minimal JS for reactivity)

STEP 3. Render on server, hydrate on client

Server (e.g., Hono):

import { Hono } from 'hono'
import { Counter } from './dist/Counter'

const app = new Hono()

app.get('/', (c) => {
  return c.html(
    <html>
      <body>
        <Counter />
        <script type="module" src="/Counter.client.js" />
      </body>
    </html>
  )
})

export default app

Client: The Client JS automatically finds elements with data-bf markers and hydrates them with reactivity.


Features

  • Zero runtime overhead (SSR) - Server renders pure templates, no JS framework needed
  • Fine-grained reactivity - Signal-based updates, only re-render what changed
  • Type-safe - Full TypeScript support with preserved type information
  • Backend agnostic - Currently supports Hono/JSX, designed for Go, Python, etc.

Documentation


License

Distributed under the MIT License. See LICENSE for more information.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •