Skip to main content
Home

Lightweight library that works with vanilla DOM elements and provides fine-grained reactivity + utils for building websites.

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
a month ago (4.0.2)
T
AnySubscriber

A signature for a subscriber function.

T
Callback

Represents a Node-style callback function that receives either an error or a result.

T
Callbackified

Represents a function that accepts a callback as its first argument, followed by any other arguments.

f
callbackify

Converts a function that returns a Promise into a function that accepts a Node-style callback.

v
default

Default export for campfire. Same as doing a synthetic import with import * as cf from "@campfire/core";

T
ElementPosition

Arg for insert().

f
empty

Empties a DOM element of its content.

f
escape

a simple HTML sanitizer. Escapes &, <, >, ', and " by replacing them with their corresponding HTML escapes (&amp;,&gt;, &lt;, &#39;, and &quot).

T
EventSubscriber

A signature for a subscriber of a specific event.

f
extend

Takes an existing element and modifies its properties. Refer ElementProperties documentation for details on what can be changed.

f
html

Creates an HTML string with automatic escaping of interpolated values. Use r() to prevent escaping specific values.

f
ids

Returns a function that generates random alphanumeric IDs with an optional prefix. Each generated ID is unique within the scope of the returned function.

f
insert

Inserts an element into the DOM given a reference element and the relative position of the new element.

c
ListStore

Reactive store for arrays, with ergonomic mutation helpers and eventing.

c
MapStore

Reactive store for string-keyed maps, with fast lookup, granular change events, and ergonomic transform/clear/has/entries helpers.

f
mustache

Renders a mustache template with the provided context data.

f
nu

Element creation/build helper. Creates a new DOM element (optionally with tag, id, and classes) and returns a chainable NuBuilder for ergonomic Campfire props and child/slot/reactivity management.

c
NuBuilder

Builder class for creating and configuring HTML elements using a fluent API.

f
onload

Fires a callback when the DOMContentLoaded event fires.

f
poll

Repeatedly executes a function at specified intervals.

f
r

Prevent values from being escaped by html``.

I
RawHtmlOptions

Options for r()

f
rm

Removes elt from the DOM.

f
select

Queries the DOM for a particular selector, and returns the first element matching it.

T
SelectParams

Params for select().

f
seq

Generates a range of numbers as an array, similar to Python's range().

c
Store

The primitive observable container. Store is the base class for all reactive state in Campfire.

f
store

Flexible reactive store creator.

T
Template

The function signature for a function returned by template().

f
template

Creates a reusable template function from a mustache template string.

f
track

Track an element by an arbitrary string id. This is essentially a global key-value store of elements you'd like to keep around.

f
tracked

Retrieve a tracked element by its id. Will return null if an element corresponding to a given id is not found.

f
unescape

Unescapes the output of escape() by replacing &amp;, &gt;, &lt;, &#39;, and &quot with &, <, >, ', and " respectively.

f
untrack

Stop tracking an element that was previously tracked by track(). If you're calling track for thousands of elements it's probably a good idea to untrack them when you're done.

f
x

Like nu(), but for existing elements—make any element reactive and ergonomic.

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.