WildflowerJS Reactive JS, No BS*

A no-build reactive JavaScript framework, rooted in the web platform.
No build step. No dependencies. No lock-in.

<script src="wildflower.min.js"></script> ...and start building.

Back to Basics

The code you write is 100% web standard code. HTML stays HTML. JavaScript stays JavaScript. CSS stays CSS. No JSX, no templating language, no custom syntax to learn. If you know the web platform, you already know how to use this.

WildflowerJS extends the web platform. It doesn't replace it.

Your Development Simplified

Because you develop with 100% web standards, every tool in your existing chain already understands the code: IDE, browser DevTools, linter, formatter, screen reader, SEO crawler. Nothing to install, no custom file types, no sourcemaps. Save the file, refresh, and your change is live.

Just be a web developer.

Batteries Included: One Mental Model

Router, SSR, stores, computed properties, two-way binding, event modifiers, data pools, and TypeScript types, all built in, all speaking the same language. Learn data-bind once and you know binding everywhere: lists, pools, stores, forms. There's no five-library stack to keep in sync.

One script tag. Everything you need.

<div data-component="counter">
  <span data-bind="count"></span>
  <button data-action="increment">
    +1
  </button>
</div>

<script>
wildflower.component('counter', {
  state: { count: 0 },
  increment() { this.count++ }
})
</script>

How It Works

data-bind connects state to the DOM.

data-action connects events to methods.

this.count++ triggers a precise DOM update.

Mutate state. The DOM updates.

Two Reactivity Modes

data-list for automatic reactivity: mutate state, DOM updates. data-pool for explicit control: plain objects, zero proxy overhead, you say what changed.

Same template syntax. Different performance profile. From interactive forms to per-frame particle systems. You choose the right tradeoff for the job.

Try it. Right-click, inspect this demo. Every dot is a real DOM element.

See full demo →

* Build Step

Zero Toolchain

Modern frameworks ask you to install a compiler, a bundler, a package manager, hundreds of fragile transitive dependencies, and a framework-specific file format, before you write a single line of your application.

WildflowerJS was built starting from a single principle: no build step, no tooling. Ever.

WildflowerJS asks you to add a script tag.

There's no CLI scaffolding step, no config files, no .vue/.jsx/.svelte source format. You don't debug through sourcemaps or wait on a build pipeline. Your project has zero dependencies.

Performance isn't a tradeoff. Build steps optimize bundle delivery, not the runtime work that follows it. WildflowerJS writes directly to the DOM, with no virtual DOM or reconciliation pass between state change and update, so it doesn't need a build step to be fast.

The framework is full-featured without the toolchain: router, SSR, stores, computed properties, transitions, pools. You don't need a toolchain to use any of it.

my-app/
  index.html
  app.js
  style.css
  wildflower.min.js

That's the entire project. No package.json.
No node_modules. No config files. Ship it.

Zero Install. Zero Attack Surface.

Every dependency you install is trust extended to a maintainer you've never met, running scripts on your dev machine and in your CI. A typical React + Vite + UI‑lib setup pulls in 300+ transitive packages before you write a feature.

Each one is a potential intrusion vector. NPM worms, OAuth chains compromising deploy platforms, postinstall hijacking: the supply chain is now where production code gets compromised, not the deploy. And signing isn't a backstop: Mini Shai‑Hulud (May 2026) compromised 170+ packages whose malicious versions carried valid SLSA Build Level 3 provenance, because the attestation came from build infrastructure the worm had already taken over.

WildflowerJS users don't have this attack surface, by construction. There is no npm install, no postinstall script, no transitive package graph. The framework is one file you copy or pin by hash.

As of v1.1, the same holds for building the framework itself. WildflowerJS bundles with a vendored rollup and terser pipeline pulled as three SHA‑512‑pinned tarballs: no npm install, no transitive packages, no postinstall scripts in the build path. The entire toolchain is three files you verify by hash.

Zero dependencies is the absence of a problem the rest of the industry has not properly addressed.

A typical React/Vue project:

  npm install
  ├── hundreds of packages
  ├── from hundreds of maintainers
  ├── postinstall scripts run on install
  └── tens to hundreds of MB of transitive code

WildflowerJS:

  <script src="wildflower.min.js"></script>
  └── 1 file.
      No transitive dependencies.

Zero Lock-in

WildflowerJS works with the DOM, not instead of it. There's no virtual DOM intercepting your code and no compiler rewriting your markup. The render cycle is yours.

That means Leaflet, DataTables, Chart.js, D3, Three.js, any library that touches the DOM, just works. No wrapper packages or framework-specific escape hatches required. Drop in a script tag and use it.

Because your code is standard HTML and JavaScript, you're never locked in. Your skills transfer and your code is more portable. If you outgrow the framework, your knowledge doesn't expire.

This also means your "ecosystem" is all of the world of vanilla JS. Without compromises or hacks.

<!-- Use any library directly -->
<div data-component="map-view">
  <div id="map" style="height: 400px"></div>
</div>
wildflower.component('map-view', {
  state: { lat: 51.505, lng: -0.09 },
  init() {
    // Leaflet works as-is. No wrappers.
    this._map = L.map('map')
      .setView([this.lat, this.lng], 13);
    L.tileLayer('https://{s}.tile.osm.org'
      + '/{z}/{x}/{y}.png').addTo(this._map);
  }
})

Precise Reactivity

When you write this.count++, WildflowerJS updates the single DOM node bound to count. Nothing else is touched. There's no tree diffing or reconciliation pass to figure that out.

This isn't a tradeoff. You get fine-grained updates and a simple mental model. Change a property, the bound element updates. That's the entire reactivity model.

Other frameworks ask you to learn signals, accessors, memos, effects, and subscription lifecycles to achieve what WildflowerJS does with a property assignment.

wildflower.component('dashboard', {
  state: {
    users: 1420,
    status: 'healthy'
  },
  computed: {
    summary() {
      return this.users + ' users, ' + this.status;
    }
  },
  refresh() {
    this.users = 1421;
    // Only the elements bound to 'users'
    // and 'summary' update. Everything
    // else on the page is untouched.
  }
})

One Reactivity Model. Everywhere.

Components, Stores, and Plugins all share the same reactive foundation. State, computed properties, and methods work identically no matter where they live. Learn it once, it works the same way in a UI component, a global store, or a framework plugin.

Other frameworks make you learn a different system for each layer. React components use hooks, but stores need Redux or Zustand, which are completely different APIs. Vue components use reactive data, but Pinia stores have their own patterns. Every layer is a new mental model.

In WildflowerJS, there's one model. A store is a component without a template. A plugin is an entity that extends the framework itself, adding directives, lifecycle hooks, and services. The same this.count++ triggers the same reactivity everywhere.

This unlocks patterns other frameworks can't express. A store can run headless physics simulations with tick(), feeding data into a component that renders it through a pool, all using the same reactive primitives, no glue code required.

// Component: reactive UI
wildflower.component('cart', {
  state: { items: [] },
  computed: {
    total() { return this.items.length; }
  }
})

// Store: global shared state
wildflower.store('user', {
  state: { name: '', role: 'guest' },
  computed: {
    isAdmin() { return this.role === 'admin'; }
  }
})

// Plugin: extends the framework
wildflower.plugin({
  name: 'notifications',
  state: { items: [], unreadCount: 0 },
  computed: {
    hasUnread() { return this.unreadCount > 0; }
  },
  add(msg) { this.items.push(msg); this.unreadCount++; }
})
// Access globally: wildflower.$notifications.add(...)

// Same state. Same computed. Same methods.

Data Pools

Every framework wraps collection items in reactive proxies, whether the item needs it or not. WildflowerJS gives you a choice: data-list for push reactivity (automatic), data-pool for pull reactivity (explicit control, zero proxy overhead).

Pools render plain objects with the same template syntax as lists. Mutate the object, call markDirty(), and only that item updates. Full CRUD, selection, bulk operations, all faster than the push-reactive path.

And because pools use pull-based rendering, they scale to simulations, games, particle systems, and data visualizations at native frame rate. Use cases that would choke a virtual DOM. No other framework has anything like this.

<div data-component="user-table">
  <tbody data-pool="users" data-key="id">
    <template>
      <tr>
        <td data-bind="name"></td>
        <td data-bind="status"
            data-bind-class="status === 'active'
              ? 'badge success'
              : 'badge inactive'"></td>
      </tr>
    </template>
  </tbody>
</div>
wildflower.component('user-table', {
  pools: { users: {} },

  init() {
    // Populate: plain objects, no proxies
    data.forEach(u => this.pools.users.add(u));
  },

  // Optional: add tick() and the same pool
  // renders every frame. Same template, same
  // data, different rendering frequency.
  // That's the only difference between a
  // display table and a particle system.
})

Built for AI-Assisted Development

Because WildflowerJS is standard HTML and JavaScript, AI code assistants already know how to write it. There's no custom syntax to hallucinate or compiler quirks to work around. The code an AI generates runs exactly as written, with no build step between generation and execution.

We go further. WildflowerJS ships an AI-optimized reference page with patterns, anti-patterns, and examples designed for code generation context windows. Our llms.txt file follows the llms.txt convention for machine-readable documentation.

And for structured app generation, our Universal App Manifest lets you describe an entire application as a JSON schema (components, state, computed properties, methods, templates) and have an AI generate the working code from the manifest, mediated through framework-specific idiom files.

You: "Build me a todo app with
WildflowerJS"

AI reads llms.txt or ai-assistant.html
     ↓
Generates standard HTML + JS
     ↓
<div data-component="todo-app">
  <input data-model="newItem">
  <button data-action="addItem">
    Add
  </button>
  <ul data-list="items">
    <template>
      <li data-bind="text"></li>
    </template>
  </ul>
</div>
     ↓
Open in your browser. It works, and you can read and understand the code.

Component Definition API

Complete reference for defining WildflowerJS components.

Basic Structure

Components are registered using wildflower.component(name, definition):

wildflower.component('component-name', {
    // Initial state
    state: { /* ... */ },

    // Derived values
    computed: { /* ... */ },

    // Props from parent
    props: { /* ... */ },

    // Type validation (dev builds)
    types: { /* ... */ },

    // State change watchers
    watch: { /* ... */ },

    // Lifecycle: called after component mounts
    init() { /* ... */ },

    // Lifecycle: called when component is destroyed
    destroy() { /* ... */ },

    // Lifecycle: called after any state change
    onUpdate(changedPaths) { /* ... */ },

    // Custom methods - available on this
    myMethod() { /* ... */ },
    anotherMethod() { /* ... */ }
});

state

Defines the component's reactive state. Changes to state properties automatically update bound DOM elements.

Type

state: object

Description

The state object contains all reactive data for the component. It can include primitives, objects, and arrays. Changes are tracked at the property level using JavaScript Proxies.

Example

wildflower.component('user-card', {
    state: {
        // Primitive values
        name: 'Alice',
        age: 28,
        isAdmin: false,

        // Nested objects
        address: {
            city: 'Portland',
            country: 'USA'
        },

        // Arrays
        tags: ['developer', 'designer'],

        // Can be null/undefined initially
        selectedItem: null
    }
});

Accessing State

// In methods
this.name = 'Bob';                 // Update triggers DOM update
this.address.city = 'NYC';         // Nested updates work
this.tags.push('artist');          // Array methods trigger updates

// Reading
const name = this.name;
const city = this.address.city;

Notes

  • State is made reactive during component initialization
  • Array methods (push, pop, splice, etc.) trigger updates
  • Deep nested changes are tracked automatically
  • Flat access is idiomatic: this.count works because ContextProxy auto-resolves state and computed properties. this.state.count also works but is more verbose. Never destructure state (const { count } = this) if you need reactivity; the destructured value is a snapshot, not reactive.

computed

Defines derived values that automatically recalculate when their dependencies change.

Type

computed: {
    [propertyName: string]: () => any
}

Description

Computed properties are getter functions that derive values from state. They're cached and only recalculate when their dependencies change.

Example

wildflower.component('profile', {
    state: {
        firstName: 'John',
        lastName: 'Doe',
        items: [
            { price: 10, quantity: 2 },
            { price: 25, quantity: 1 }
        ],
        taxRate: 0.08
    },

    computed: {
        // Simple derived value
        fullName() {
            return `${this.firstName} ${this.lastName}`;
        },

        // Computed from array
        subtotal() {
            return this.items.reduce(
                (sum, item) => sum + (item.price * item.quantity),
                0
            );
        },

        // Computed from other computed
        total() {
            const sub = this.subtotal;
            return sub + (sub * this.taxRate);
        },

        // Boolean computed
        hasItems() {
            return this.items.length > 0;
        },

        // Filtered list
        expensiveItems() {
            return this.items.filter(item => item.price > 20);
        }
    }
});

HTML Usage

<div data-component="profile">
    <h2 data-bind="fullName"></h2>
    <p>Subtotal: $<span data-bind="subtotal"></span></p>
    <p>Total: $<span data-bind="total"></span></p>

    <!-- In conditionals -->
    <div data-show="hasItems">
        You have items in your cart
    </div>

    <!-- As list source -->
    <ul data-list="expensiveItems">
        <template><li data-bind="name"></li></template>
    </ul>
</div>

Accessing in Methods

// Access computed values directly on this
someMethod() {
    const name = this.fullName;
    const total = this.total;
}

In List Templates

Computed properties can access list item context:

wildflower.component('order', {
    state: {
        items: [
            { name: 'Widget', price: 10, qty: 2 },
            { name: 'Gadget', price: 25, qty: 1 }
        ]
    },

    computed: {
        // When used in a list template, 'this' has item properties
        lineTotal() {
            return (this.price || 0) * (this.qty || 0);
        }
    }
});
<ul data-list="items">
    <template>
        <li>
            <span data-bind="name"></span>:
            $<span data-bind="lineTotal"></span>
        </li>
    </template>
</ul>

props

Defines properties that can be passed from parent components or HTML attributes.

Type

props: {
    [propName: string]: {
        type?: 'string' | 'number' | 'boolean' | 'object' | 'array',
        default?: any,
        required?: boolean
    }
} | string[]

Description

Props allow parent components to pass data to children. Props are read from data-prop-* attributes on the component element.

Simple Array Syntax

wildflower.component('greeting', {
    props: ['name', 'greeting'],

    computed: {
        message() {
            return `${this.props.greeting || 'Hello'}, ${this.props.name}!`;
        }
    }
});

Object Syntax with Validation

wildflower.component('user-badge', {
    props: {
        userId: {
            type: 'number',
            required: true
        },
        size: {
            type: 'string',
            default: 'medium'
        },
        showAvatar: {
            type: 'boolean',
            default: true
        }
    },

    init() {
        console.log('User ID:', this.props.userId);
        console.log('Size:', this.props.size);
    }
});

HTML Usage

<!-- Props passed via data-prop-* attributes -->
<div data-component="user-badge"
     data-prop-user-id="42"
     data-prop-size="large"
     data-prop-show-avatar="true">
</div>

<!-- In a list context, pass item data -->
<ul data-list="users">
    <template>
        <li>
            <div data-component="user-badge"
                 data-prop-user-id="id">
            </div>
        </li>
    </template>
</ul>

Notes

  • Props are converted to camelCase: data-prop-user-id becomes this.props.userId
  • Type coercion: "42" becomes 42 for number type, "true" becomes true for boolean
  • Props are read-only - don't modify them directly
  • In dev builds, type validation warnings appear in console

types

Defines runtime type validation for state properties (development builds only).

Type

types: {
    [propertyPath: string]: 'string' | 'number' | 'boolean' |
                            'object' | 'array' | 'function' | 'any'
}

Description

When running a development build, the framework validates state changes against declared types and logs warnings for mismatches.

Example

wildflower.component('typed-form', {
    state: {
        name: '',
        age: 0,
        isActive: true,
        tags: [],
        metadata: {}
    },

    types: {
        name: 'string',
        age: 'number',
        isActive: 'boolean',
        tags: 'array',
        metadata: 'object'
    },

    updateAge(newAge) {
        // In dev build: warns if newAge isn't a number
        this.age = newAge;
    }
});

Nested Property Types

wildflower.component('nested-types', {
    state: {
        user: {
            name: '',
            profile: {
                bio: '',
                age: 0
            }
        }
    },

    types: {
        'user.name': 'string',
        'user.profile.bio': 'string',
        'user.profile.age': 'number'
    }
});

Notes

  • Type validation is stripped from production builds for performance
  • Warnings appear in the console but don't throw errors
  • Use with TypeScript definitions for full type safety

watch

Defines callbacks that run when specific state properties change.

Type

watch: {
    [propertyPath: string]: (newValue: any, oldValue: any) => void
}

Description

Watchers let you react to specific state changes with custom logic, useful for side effects like API calls, localStorage updates, or analytics.

Example

wildflower.component('settings', {
    state: {
        theme: 'light',
        language: 'en',
        notifications: true
    },

    watch: {
        // Simple watcher
        theme(newTheme, oldTheme) {
            document.body.className = `theme-${newTheme}`;
            console.log(`Theme changed from ${oldTheme} to ${newTheme}`);
        },

        // Watcher with side effect
        language(newLang) {
            this.loadTranslations(newLang);
        },

        // Boolean watcher
        notifications(enabled) {
            if (enabled) {
                this.requestNotificationPermission();
            }
        }
    },

    loadTranslations(lang) {
        // Load language file...
    },

    requestNotificationPermission() {
        // Request browser permission...
    }
});

Watching Nested Properties

wildflower.component('profile', {
    state: {
        user: {
            name: '',
            settings: {
                darkMode: false
            }
        }
    },

    watch: {
        // Watch nested property
        'user.settings.darkMode'(isDark) {
            document.body.classList.toggle('dark', isDark);
        }
    }
});

Notes

  • Watchers run after the DOM has been updated
  • Use dot notation for nested property paths
  • Watchers receive both new and old values
  • Avoid modifying watched properties in the watcher (can cause loops)

beforeInit()

Lifecycle method called after methods are bound but before bindings are processed.

Signature

beforeInit(): void

Description

Called once after the component's methods are bound to the context, but before data-bind, data-action, and other bindings are processed. Useful for setting up initial state that depends on props or list item data before the DOM is rendered.

Available Context

beforeInit() {
    this.element;    // The root DOM element
    this.state;      // Reactive state object
    this.props;      // Read-only props from parent
    this.listItem;   // List item data (if inside data-list)
    this.stores;     // Subscribed store references
    this.myMethod(); // Custom methods are available
}

Example

wildflower.component('item-card', {
    state: {
        displayName: '',
        priority: 'normal'
    },

    props: ['itemId'],

    beforeInit() {
        // Set up state from list item data before bindings render
        if (this.listItem) {
            this.displayName = this.listItem.name;
            this.priority = this.listItem.priority || 'normal';
        }
    }
});

Notes

  • Called before any DOM bindings are processed; the DOM still shows initial template content
  • this.listItem is already available at this point
  • Use this for pre-binding state setup; use init() for post-binding logic

init()

Lifecycle method called after the component mounts and initial bindings are created.

Signature

init(): void

Description

Called once after the component element is bound and all child bindings are set up. Use for initialization logic, fetching data, setting up subscriptions, etc.

Available Context

init() {
    // Component element
    this.element;           // The root DOM element

    // State and computed
    this.state;             // Reactive state object
    this.computed;          // Computed properties

    // Props from parent
    this.props;             // Read-only props

    // Component identity
    this.name;              // Component name (e.g., 'user-card')
    this.id;                // Unique component instance ID

    // Methods are available
    this.myMethod();        // Call your own methods
}

Example

wildflower.component('data-loader', {
    state: {
        data: null,
        loading: true,
        error: null
    },

    props: ['endpoint'],

    async init() {
        try {
            const response = await fetch(this.props.endpoint);
            this.data = await response.json();
        } catch (err) {
            this.error = err.message;
        } finally {
            this.loading = false;
        }
    }
});

Common Patterns

init() {
    // DOM queries within component
    this.canvas = this.element.querySelector('canvas');

    // Event listeners for non-declarative events
    window.addEventListener('resize', this.handleResize);

    // Store subscriptions
    wildflower.getStore('auth').subscribe(
        'isLoggedIn',
        (value) => this.loggedIn = value
    );

    // Timers
    this.interval = setInterval(() => this.tick(), 1000);
}

Notes

  • Called after all data-bind, data-action, etc. are processed
  • Child components may not be initialized yet
  • Can be async - framework doesn't await it
  • Clean up any subscriptions/listeners in destroy()

beforeDestroy()

Lifecycle method called before component cleanup starts.

Signature

beforeDestroy(): void

Description

Called once before the component's cleanup begins. Mirrors beforeInit() for teardown. Use it for any logic that must run while the component's bindings, subscriptions, and child components are still active.

Example

wildflower.component('dashboard-panel', {
    state: {
        visible: true
    },

    beforeDestroy() {
        // Notify other components while still fully active
        const metrics = wildflower.getStore('metrics');
        metrics.panelClosed(this.element.id);
    },

    destroy() {
        // Standard cleanup: bindings already being torn down
        clearInterval(this.interval);
    }
});

Notes

  • Called before destroy(); bindings and children are still active
  • The plugin system hooks into this as component:beforeDestroy
  • Use for pre-teardown communication; use destroy() for resource cleanup

destroy()

Lifecycle method called before the component is removed from the DOM.

Signature

destroy(): void

Description

Called when the component is about to be destroyed. Use for cleanup: removing event listeners, clearing timers, unsubscribing from stores, etc.

Example

wildflower.component('live-chart', {
    state: { data: [] },

    init() {
        // Set up listeners and intervals
        this.handleResize = this.handleResize.bind(this);
        window.addEventListener('resize', this.handleResize);

        this.interval = setInterval(() => this.fetchData(), 5000);

        this.unsubscribe = wildflower.getStore('metrics')
            .subscribe('values', (v) => this.data = v);
    },

    destroy() {
        // Clean up everything
        window.removeEventListener('resize', this.handleResize);
        clearInterval(this.interval);
        this.unsubscribe();
    },

    handleResize() {
        // Resize chart...
    },

    fetchData() {
        // Fetch new data...
    }
});

When destroy() is Called

  • Component element is removed from DOM
  • data-render condition becomes false
  • Parent component is destroyed
  • wildflower.destroyComponent(id) is called
  • Framework's destroy() method is called

beforeUpdate()

Lifecycle method called before DOM updates are applied.

Signature

beforeUpdate(): void

Description

Called before the framework applies DOM updates after a state change. Useful for capturing DOM measurements or state before the DOM is modified (e.g., scroll positions, element dimensions).

Example

wildflower.component('chat-log', {
    state: {
        messages: []
    },

    beforeUpdate() {
        // Capture scroll position before DOM updates
        const container = this.find('.messages');
        this._wasAtBottom = container.scrollTop + container.clientHeight
            >= container.scrollHeight - 10;
    },

    onUpdate() {
        // Restore scroll position after DOM updates
        if (this._wasAtBottom) {
            const container = this.find('.messages');
            container.scrollTop = container.scrollHeight;
        }
    }
});

Notes

  • Called before every DOM update cycle; use sparingly for performance
  • No parameters are passed
  • The DOM still reflects the previous state when this runs

onUpdate()

Lifecycle method called after any state change and DOM update.

Signature

onUpdate(changedPaths?: string[]): void

Description

Called after every state change once the DOM has been updated. Useful for side effects that need to run after any change, or for integrating with third-party libraries that need to know when the DOM changed.

Parameters

ParameterTypeDescription
changedPaths string[] Array of state paths that changed (e.g., ['count', 'user.name'])

Example

wildflower.component('chart', {
    state: {
        data: [],
        options: { type: 'bar' }
    },

    init() {
        this.chart = new ThirdPartyChart(
            this.element.querySelector('.chart-container'),
            this.data,
            this.options
        );
    },

    onUpdate(changedPaths) {
        // Re-render chart when data changes
        if (changedPaths.includes('data')) {
            this.chart.setData(this.data);
        }

        // Update chart type when options change
        if (changedPaths.some(p => p.startsWith('options'))) {
            this.chart.setOptions(this.options);
        }
    },

    destroy() {
        this.chart.destroy();
    }
});

Notes

  • Called after every state change - use sparingly for performance
  • DOM is already updated when this runs
  • Check changedPaths to avoid unnecessary work
  • Don't modify state in onUpdate unless absolutely necessary (can cause loops)

tick(dt, now)

Lifecycle method called every animation frame via requestAnimationFrame.

Signature

tick(dt: number, now: number): void

Description

Called on every animation frame when defined. Components with a tick method are automatically registered in the framework's shared requestAnimationFrame loop. Pool flush happens after all tick callbacks run.

Parameters

ParameterTypeDescription
dt number Milliseconds since the last frame, clamped to a maximum of 250ms to prevent large jumps after tab suspension
now number Current timestamp from requestAnimationFrame

Example

wildflower.component('particle-system', {
    state: {
        x: 0,
        y: 0,
        velocityX: 100,  // pixels per second
        velocityY: 50
    },

    tick(dt, now) {
        // dt is in milliseconds; convert to seconds for physics
        const seconds = dt / 1000;
        this.x += this.velocityX * seconds;
        this.y += this.velocityY * seconds;
    }
});

Notes

  • The rAF loop starts automatically when any component with tick is initialized
  • The loop stops when all tickable components are destroyed
  • dt is clamped to 250ms to prevent physics explosions after tab suspension
  • Pool flush runs after tick callbacks, so pool mutations in tick are batched efficiently

onError(error, context)

Error boundary hook called when an error occurs during any lifecycle phase.

Signature

onError(error: Error, context: { lifecycle: string }): void

Description

Provides per-component error handling. When defined, the framework routes errors from lifecycle methods (init, beforeInit, onUpdate, etc.) to this handler instead of throwing.

Parameters

ParameterTypeDescription
error Error The error that occurred
context object Object with a lifecycle key indicating where the error occurred (e.g., 'init', 'beforeInit', 'subscribe-wait')

Example

wildflower.component('resilient-widget', {
    state: {
        data: null,
        errorMessage: null
    },

    async init() {
        const response = await fetch('/api/data');
        this.data = await response.json();
    },

    onError(error, context) {
        console.warn(`Error in ${context.lifecycle}:`, error.message);
        this.errorMessage = 'Something went wrong. Please try again.';
    }
});

Notes

  • Acts as an error boundary for the component's own lifecycle methods
  • The context.lifecycle key tells you which phase failed
  • Use this.resetError() to recover from an error state

onPropsChange(propsChangeInfo)

Lifecycle method called when parent-passed props change.

Signature

onPropsChange(propsChangeInfo: object): void

Description

Called when one or more props passed from a parent component change. Computed properties are flushed before this hook runs, so derived values are up to date.

Example

wildflower.component('filtered-list', {
    props: {
        filter: { type: 'string', default: '' }
    },

    state: {
        items: [],
        filteredItems: []
    },

    onPropsChange(info) {
        // Re-filter when the parent changes the filter prop
        this.filteredItems = this.items.filter(
            item => item.name.includes(this.props.filter)
        );
    }
});

Notes

  • Only called when props actually change, not on initial render
  • Computed properties are already recalculated when this runs
  • The propsChangeInfo parameter contains information about which props changed

Methods

Custom methods defined at the top level of the component definition.

Description

Any function defined at the top level of the component definition becomes a method, available on this and bindable via data-action.

Example

wildflower.component('counter', {
    state: { count: 0 },

    // These are all methods
    increment() {
        this.count++;
    },

    decrement() {
        this.count--;
    },

    reset() {
        this.count = 0;
    },

    setCount(value) {
        this.count = value;
    },

    // Async methods work too
    async fetchCount() {
        const response = await fetch('/api/count');
        const data = await response.json();
        this.count = data.count;
    },

    // Private convention: prefix with underscore
    _validateCount(value) {
        return typeof value === 'number' && !isNaN(value);
    }
});

Action Handler Signature

Methods bound via data-action receive these parameters:

handleClick(event, element, context) {
    // event   - The DOM event object
    // element - The element that triggered the event
    // context - Object with additional info:
    //   context.index - Index when in a list
    //   context.item  - Current item when in a list
}

List Action Example

wildflower.component('todo-list', {
    state: {
        todos: [
            { id: 1, text: 'Task 1', done: false },
            { id: 2, text: 'Task 2', done: true }
        ]
    },

    toggle(event, element, context) {
        // context.index is the position in the list
        this.todos[context.index].done =
            !this.todos[context.index].done;
    },

    remove(event, element, context) {
        this.todos.splice(context.index, 1);
    }
});

Instance Properties

Properties available on this inside component methods.

PropertyTypeDescription
this.element HTMLElement The component's root DOM element
this.state object Reactive state object
this.computed object Computed properties (read via getters)
this.props object Read-only props from parent
this.name string Component name (e.g., 'user-card')
this.id string Unique component instance ID
this.listItem object | null List item data when this component is rendered inside a data-list. null if not in a list. Available from beforeInit() onward.
this.pools object Object containing pool handles when pools: {} is declared in the component definition
this.stores object Object containing subscribed store references declared via subscribe:. Access as this.stores.storeName.
this.emit(eventName, data) function Emit a custom event to the parent component. Parent handles via onEventName method.
this.$el(selector) function Scoped jQuery-like DOM query helper (WildQuery). Returns a chainable wrapper scoped to the component element.
this.find(selector) function Scoped querySelector: searches only within this component's element
this.findAll(selector) function Scoped querySelectorAll: searches only within this component's element
this.closest(selector) function Traverses up the DOM from the component's root element using Element.closest()

Example

wildflower.component('example', {
    state: { count: 0 },

    computed: {
        doubled() { return this.count * 2; }
    },

    init() {
        console.log('Element:', this.element);
        console.log('Name:', this.name);      // 'example'
        console.log('ID:', this.id);          // 'example-abc123'
        console.log('Count:', this.count);
        console.log('Doubled:', this.doubled);
    }
});