Loading...
Loading...
Build and change web apps with Jadis (`@jadis/core`), a thin layer over native Web Components where real DOM is drawn once and changed by hand, with no virtual DOM, no reactivity and no framework runtime. Teaches it from zero (the lifecycle, JSX or createElement templates, state with useChange, attributes, events, buses, routing, translations, server rendering with @jadis/fastify, tests), the mistakes that React, Vue and Lit habits cause in it, and a self-check to run before delivering. Load it before writing, reviewing or debugging code that imports `@jadis/core`, extends `Jadis`, calls `useRefs`, `useChange`, `useEvents`, `useAttributes`, `onBus`, `Router` or `Translator`, sets `jsxImportSource` to `@jadis/core`, or uses `@jadis/fastify` or `@jadis/create`, and before starting an app on Jadis, even when the request only says web components or custom elements in a project that depends on Jadis.
npx skill4agent add bioleyl/jadis jadis-officialJadis@jadis/core@1.9.1AGENTS.mdCLAUDE.md| You would write (React, Vue, Lit) | In Jadis |
|---|---|
| A function or class that renders again on every change | |
| |
JSX in | JSX in |
| |
| |
| Props | Public fields and methods; JSX props set properties; attributes through |
Callback props, | |
| Context, Redux, Pinia, stores | A |
| You add, move and remove the row elements yourself, usually from a |
| React Router, vue-router | |
| i18n libraries | |
// src/components/quantity-stepper.tsx
import { Jadis } from '@jadis/core';
import styles from './quantity-stepper.css?inline';
const MIN_QUANTITY = 1;
export class QuantityStepper extends Jadis {
// A custom element name: lowercase, with a hyphen, unique in the app.
static readonly selector = 'quantity-stepper';
// Public and named `events`: a parent registers on it, and JSX accepts `onValueChange`.
readonly events = this.useEvents<{ valueChange: number }>();
// The state. The `value` attribute, a JSX prop `value={3}` and `stepper.value.set(3)` all set it.
readonly value = this.useChange(MIN_QUANTITY, (value) => this.drawValue(value), { attribute: 'value' });
// Getters on the template: each access queries the shadow root. Never read them in the constructor.
private readonly _refs = this.useRefs((ref) => ({
decrease: ref<HTMLButtonElement>('#decrease'),
increase: ref<HTMLButtonElement>('#increase'),
output: ref('output'),
}));
// Runs once, at the first connection. Structure only: the callbacks fill in the values.
templateHtml(): Node {
return (
<div class="stepper">
<button id="decrease" type="button" aria-label="Decrease">−</button>
<output />
<button id="increase" type="button" aria-label="Increase">+</button>
</div>
);
}
templateCss(): string {
return styles;
}
// A task after each connection. Listeners added with this.on() go at disconnection.
onConnect(): void {
this.on(this._refs.decrease, 'click', () => this.step(-1));
this.on(this._refs.increase, 'click', () => this.step(1));
}
private step(delta: number): void {
this.value.set((value) => Math.max(MIN_QUANTITY, value + delta));
this.events.emit('valueChange', this.value.get());
}
// Draws the value it is given, whole: it may run again with the same value.
private drawValue(value: number): void {
this._refs.output.textContent = String(value);
this._refs.decrease.disabled = value <= MIN_QUANTITY;
}
}
QuantityStepper.register();/* src/components/quantity-stepper.css */
:host { display: inline-block; }
.stepper { display: flex; align-items: center; gap: 0.5rem; }<QuantityStepper value={2} onValueChange={(quantity) => this.drawTotal(quantity)} /><quantity-stepper value="2"></quantity-stepper>useRefsuseChangeuseEventsuseAttributesappendChildtemplateCss()templateHtml()useChangeimmediateuseTranslationonConnect()setTimeoutappendChildthis.on()events.register()onBus()onDisconnect()onConnect()appendinsertBeforereplaceChildrenmoveBeforeonConnect()this.killSignalfetchthis.isConnectedawaittemplateHtml()textContentclassList.toggletemplateHtml()innerHTMLuseChangeset((list) => [...list, item])on…this.on()onConnect()windowdocumentonConnect()this.on()onBus()events.register(){ signal: this.killSignal }removeEventListeneronConnectconnectedCallbackdisconnectedCallbackattributeChangedCallbackstatic observedAttributesonConnectonDisconnectuseAttributesuseChange(…, { attribute })static readonly selectorregister()useChangethis.events.emit()readonly eventsBus<user-card name="Ada" />element.namenameattrs={{ name: 'Ada' }}data-*aria-*textContenttextContentinnerHTMLtemplateCss():host { display: block; }HTMLElementtitlehiddenidlangdirstyleslottranslateremoveclickfocusisConnectedfetchURLIntl<form><dialog><template>appendChildonConnect| When you | Read |
|---|---|
| Start a project, set up Vite, TypeScript, JSX, plain JavaScript, or no build step | references/setup.md |
Write a component: refs, | references/components.md |
Write templates: JSX rules, lists, conditions, forms, | references/templating.md |
| Connect components: parent and child, events, buses, services | references/communication.md |
Add pages and navigation: routes, links, parameters, query, | references/routing.md |
| Translate the app | references/translations.md |
Render on the server, or with | references/server-rendering.md |
| Write tests (Vitest, jsdom, Playwright) | references/testing.md |
| Want a worked example: a list, a form, a page that loads data, a dialog, an app shell | references/recipes.md |
| Need a signature | references/api.md |
| Are new to Jadis, or review code | references/agent-mistakes.md |
versionnode_modules/@jadis/core/package.jsonnode_modules/@jadis/core/dist/dts/base-component.d.tsJadishelpers/router/translation/server/https://raw.githubusercontent.com/bioleyl/jadis/core-v<version>/packages/docs/<section>/<page>.md/routing/routed-pagesrouting/routed-pages.mdnpm view @jadis/core version@syware/jlibjl-*jlibinnerHTMLuseChangeonConnect()this.on()onBus()events.register()removeEventListeneronConnect()this.killSignalfetchthis.isConnectedawaitobservedAttributesregister():hostreadonly eventsattrstextContentinnerHTMLHTMLElement<file>:<line> — <what changed>jadis self-check: 2 fixedjadis self-check: cleangh issue list --repo bioleyl/jadis --search "…"gh issue create --repo bioleyl/jadis