Skip to main content

Introduction

Nodes are backend-defined UI blocks. A route or controller returns a root node response; React renders the serialized node tree.

Use nodes when PHP owns the workflow or layout decision. Use normal React routes when the frontend owns most of the state and behaviour.

Simple Page

Route:

use App\Http\Controllers\DashboardController;
use Illuminate\Support\Facades\Route;

Route::middleware(qore()->getAuthMiddleware())
->get('/api/dashboard', DashboardController::class);

Controller:

namespace App\Http\Controllers;

use Qore\Next\System\Nodes\CardNode;
use Qore\Next\System\Nodes\PageNode;
use Qore\Next\System\Nodes\TextNode;

class DashboardController
{
public function __invoke()
{
$page = new PageNode('Dashboard');

$page->addChild(
(new CardNode('Status'))
->addChild(new TextNode('Everything is up to date.'))
);

return $page->toResponse();
}
}

toResponse() creates a NodeManager, runs the node request lifecycle, runs the node response lifecycle and returns JSON.

Common Node Methods

  • addChild(Node $node): static: append a child.
  • addFlex(Closure(FlexNode): void $closure): static, addCard(Closure(CardNode): void $closure): static, addText(string $title, ?Closure(TextNode): void $closure = null): static: small builder helpers.
  • setId(string $id): static: needed for state, visibility and external reloads.
  • setClassName(string $className): static, addClassName(string $className): static: CSS classes.
  • setProperty(string $key, mixed $value): static, setProperties(array $properties): static: custom frontend props.
  • setIsHiddenByDefault(bool $hide = true): static: first response starts hidden.
  • onNodeRequest(Closure(NodeManager): void $callback): static: run before serialization.
  • onNodeResponse(Closure(NodeManager): void $callback): static: run after request callbacks, before serialization.

Resource pages use nodes internally, so custom nodes fit naturally when a resource detail page, action or field needs a richer backend-driven UI.