Skip to content

Support a public route manifest for metadata and route-change integrations #15

Description

@xusd320

Problem

EVJS applications use TanStack Router as the page routing system, and route metadata can be modeled with staticData. For larger apps, the same route metadata is often also needed outside route components, for example:

  • navigation menus and breadcrumbs
  • document title and page labels
  • access-control checks
  • route-level analytics or page-view integrations
  • route-change listeners that need matched route metadata and params

Today there does not appear to be a public EVJS helper that exposes a normalized route manifest or a route-match state derived from the app route tree. Apps that need these integrations usually end up duplicating route metadata or writing ad-hoc traversal/matching code around the router.

Proposal

Add a public route manifest capability to EVJS that is derived from the existing TanStack Router route tree. This should not introduce a second routing system; it should be a metadata/introspection layer for the existing route tree.

Possible API shape:

import {
  createRouteManifest,
  matchRouteManifest,
  subscribeRouteManifest,
} from "@evjs/client";

const manifest = createRouteManifest(routeTree);

const state = matchRouteManifest(manifest, "/projects/42");
// state.params, state.matches, state.route?.staticData

const unsubscribe = subscribeRouteManifest(router, manifest, (event) => {
  // event.location, event.params, event.matches, event.route?.staticData
});

Expected Behavior

The route manifest should preserve enough information for common app-level integrations:

  • route id
  • path and full path
  • index/pathless/layout route information
  • parent/children relationship
  • staticData / route metadata
  • matched route list for a location
  • decoded route params

It should support TanStack Router path conventions such as $param, index routes, and pathless layout routes.

Acceptance Criteria

  • EVJS exposes a documented route manifest or route metadata introspection API.
  • The API is derived from the app route tree and does not require duplicating route definitions.
  • Consumers can get matched route metadata and params for the current location.
  • Consumers can subscribe to route changes and receive matched metadata without reimplementing router traversal.
  • Documentation includes examples for menus, breadcrumbs, page title, and analytics integrations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions