Skip to content
Guide

Add an App report to a dashboard

Run the generated Note count report and place it on a dashboard.

Add an App report to a dashboard

Use authorized reports for standard metrics, tables and charts. This first example counts Notes; it needs no per-report React component or iframe. Complete Note creation and saving in Create a Resource first.

Inspect the generated report

The current generator's src/Contribution/Resources/NoteModule.php already implements ReportContribution and includes reports() in this form. Do not add a duplicate method or report. Its ReportDefinition import is already present.

Code example
PHP
public static function reports(): array
{
    return [ReportDefinition::count(
        self::resourceKey().'.count',
        'workshop.note.list.title',
        self::resourceKey(),
    )];
}

Keep your generated identifiers if the App is not Workshop. ReportDefinition::count() creates an authorized Composition query and MetricCard presentation. It counts readable records, not a loaded UI page or unrestricted SQL rows.

Verify the dashboard widget

  1. Wait for declaration synchronization and readiness in nexia dev.
  2. Assign Note read permission and the required legal-entity scope to the user. Access to the Report and Dashboard screens is also required.
  3. Open the Note report from the Manage reports list and compare it with the Note count for the same user and query scope.
  4. In dashboard editing, use the Reports tab to place the report and save.
  5. Reopen it, then create a Note and refresh the query to check the changed count.
  6. Verify an existing placement does not reveal data after the viewer loses read permission. Never reuse another user's result.

If the report is missing, follow Troubleshoot App declarations. Use Save a copy to edit a user-owned version of the App template. Sharing grants no source-data access, and a dashboard placement pins the report revision.

Choose a richer presentation

GoalPath
Record countReuse generated ReportDefinition::count()
Table, chart or pivotDefine a CompositionSpec and report presentation for permitted public fields and aggregates
Create, edit or approve business recordsA React business screen and protected API from Build an App screen

List filtering and sorting do not automatically publish analytics fields. Richer reports need safe Resource descriptor composition fields, aggregates and units. Do not bypass this with cross-App table joins or numeric primary keys. This guide covers the generated count report, not the complete custom-chart or slot-widget API.

Check supported report queries before using grouped aggregates or custom Composition plans in an isolated App.

Custom widget queries

Custom widgets use useWidgetQueryRuntime() from @nexia/sdk/host and call the surrounding runtime's query(tool, args, signal). Do not call a query URL directly from a widget. The host selects the Shell or isolated App transport; the server checks the declared source and user authority. The queryRef and existing response contracts stay unchanged, and queries cannot create, update or delete business data. Adopt the SDK and Core implementations together before migrating consuming Apps.

Existing Apps and adoption order

Separate App overview screens are deprecated. For a new overview, use the SDK's report and dashboard contracts to provide a platform dashboard rather than building a separate screen. Business screens for creating, editing, or approving work are outside this deprecation.

A default dashboard declaration remains optional in the current runtime, and an App without one continues to use its existing overview. An existing separate overview is not automatically removed or converted to a dashboard, and user edits to saved dashboards are preserved. No removal date has been set. The current generator still creates an overview file. Retain the generated route as required by the current runtime and do not add separate overview features. Before removing an existing route, provide the required information and actions on the dashboard and verify compatibility.

Do not assume an existing widget follows the dashboard's Legal Entity selection until its source declares and applies that scope. An existing overview's selector continues to follow that screen's own implementation.

Use the contracts below only when the PHP and React SDKs, Core, and App runtime that provide them are all available. Before deployment, check the provided SDK versions and your project's dependency locks, and align development and deployment environments. An App that does not use the new contracts can adopt them later. Verify existing widgets and reports against their actual queries and data.

Declare an App default dashboard

Return the keys of already registered widgets in display order. An App may have one implementation; keys must be unique and belong to widgets registered by that App.

Code example
PHP
use Nexia\Dashboard\Contracts\DashboardDefaultContribution;

final class DefaultDashboard implements DashboardDefaultContribution
{
    public static function dashboardDefaultWidgetKeys(): array
    {
        return ['workshop.note_count']; // An already registered App widget key
    }
}

An empty array declares an editable empty default dashboard. Omitting the declaration keeps the existing overview. Users can edit a provided default dashboard. To preserve the cards and navigation links from an existing overview, declare the corresponding widgets and actions in the App.

Widget height

With Laravel SDK 0.11.6 and Core 0.12.1 or later, pass height: ['minRows' => 8, 'defaultRows' => 24, 'maxRows' => null] as a named argument when constructing a DashboardWidget. The values are grid rows. Use positive integers with minRows <= defaultRows <= maxRows when the maximum is set. An explicit null maximum leaves manual growth uncapped by the widget. New placements use defaultRows. Saved widgets keep their saved height and apply the current limits when resized. Verify a new placement and resize a saved widget before submitting the App. See the Laravel SDK contract.

Classify each App DashboardQuerySource according to the data it reads.

DataDeclarationBehavior
Data for selected Legal EntitieslegalEntityScope: 'selected', usesLegalEntitySelection: trueApply all selected Legal Entities to the query
Data independent of Legal Entity selection, such as a personal notelegalEntityScope: 'independent', usesLegalEntitySelection: falseKeep the same scope when the selection changes

This example adds both arguments to an existing DashboardQuerySource constructor. Replace the key, path, and permission with values registered by your App.

Code example
PHP
use Nexia\Dashboard\DashboardQuerySource;
use Nexia\Permission\SubjectPopulation;

new DashboardQuerySource(
    key: 'workshop.note_summary.read',
    description: 'Note summary',
    path: '/api/workshop/dashboard/note-summary',
    permission: 'workshop.note.read',
    subjectPopulation: SubjectPopulation::LegalEntity,
    usesLegalEntitySelection: true,
    legalEntityScope: 'selected',
);

In the handler, use Nexia\Laravel\Dashboard\DashboardWidgetSelection::legalEntityPublicIds($request) to read the selected public IDs as an array. Handle both one and multiple IDs, and filter using the data's actual Legal Entity relationship. A null result means this is not a dashboard widget request with a Legal Entity selection; preserve the handler's ordinary request behavior. Do not interpret null as permission to read unrestricted data. Selection does not grant access: continue to enforce the user's existing permissions and row-level scope.

Reports and verification

Do not duplicate a report definition for each widget. A standalone report uses its own Legal Entity selection; a report placed on a dashboard uses the dashboard's selection. Its source must return rows for the selected entities. To opt an existing report filter for a tenant-owned Resource into dashboard Resource queries, first ensure the filter handles multiple Legal Entities and the current actor correctly, then implement DashboardReportLegalEntityFilter. This declaration does not grant access. See governed report queries for supported queries and source-specific implementation.

After conversion, use nexia check and nexia dev to check discovery. Compare actual counts for one and multiple Legal Entities in both standalone reports and dashboards. Also check a user authorized for one entity, an unauthorized entity, and personal widgets independent of the selection. Verify existing screens and saved widgets that the App uses, and confirm that an App without a new default dashboard retains its existing overview.

Register the same query key used by useQuery with useDashboardDataSource(queryKey, runtime.supportsRealtimeInvalidation && enabled && !preview) from @nexia/sdk/host. This connects the widget to its own dashboard’s refresh button and update time; previews must not register. Both hooks reuse existing Core runtime and refresh registration.

See the public CLI documentation for command and option details.

Self-scoped composite reads

A human DashboardQuerySource with SubjectPopulation::Self can check other read permissions declared by the same App using SubjectPermissionAuthorizer::allowsSubjectPopulation(..., SubjectPopulation::Self, ...). Each decision requires the user's effective grant in the exact signed organization scope. The source's declared entry permission remains required; a supplementary permission alone does not admit the source.

Keep explicit actor/employment and legal-entity filters on every App query. These decisions do not grant general PermissionAuthorizer access, write permissions, other subject populations, cross-App permissions, or additional Agent authority. Recheck after revoking a grant. Adoption requires the corresponding Core release, with no SDK API change.

Source of truth: docs/developers/content/en/platform-extensions/add-dashboard-widget.md