Astro-DX Logo Astro-DX
GitHub
Docs

Quick start

Get up and running with astro-dx in minutes.

astro-dx is a community library, not affiliated with the Astro core team.

1. Install

npx @astro-dx/init

2. Create a signal

"code-keyword">import { signal, computed } "code-keyword">from '@astro-dx/core';
"code-keyword">import { getElement } "code-keyword">from '@astro-dx/dom';

"code-keyword">const count = "code-function">signal(0);
"code-keyword">const double = "code-function">computed(() => "code-function">count() * 2);

"code-function">getElement('#count')."code-function">text(count);
"code-function">getElement('#btn')."code-function">on('click', () => count."code-function">update(v => v + 1));

3. Share state via a service

"code-keyword">import { signal, computed } "code-keyword">from '@astro-dx/core';

"code-keyword">class CartServiceClass {
  private _items = signal<"code-type">string[]>([]);
  readonly total = "code-function">computed(() => "code-keyword">this."code-function">_items().length);

  "code-function">add(item: "code-type">string) { "code-keyword">this._items."code-function">update(p => [...p, item]); }
  "code-function">clear() { "code-keyword">this._items."code-function">set([]); }
}


"code-keyword">export "code-keyword">const CartService = "code-keyword">new "code-function">CartServiceClass();

Explore the docs

Installation All install options — CLI, all-in-one, granular
@astro-dx/core signal, computed, effect, lifecycle hooks
@astro-dx/events on, onHover, onKey, onFocus
@astro-dx/attributes dx-if, dx-show, dx-for as attributes
@astro-dx/elements dx-if, dx-show, dx-for as custom elements
@astro-dx/dom getElement, getElements, enriched refs