Symbolic navigation · TypeScript

Anchor Routing

Name a destination. Bind its arguments. Let your application’s router handle navigation.

A library for parsing four explicit route forms into structured instructions, validating them against your registry, and resolving route records for framework adapters.

Project activeSpecification draftSoftware Apache-2.0Core source 0.2.1 · unreleased patch

The playground uses the unreleased core patch. Published package versions and source downloads are listed in Packages.

Four forms, one registry

Choose a form for what the route expresses. Ordinary resource URLs can stay ordinary URLs.

Page case

/settings~security

A section within a named page. The registry resolves the page and section together.

Param case

/~profile;42

A symbolic key with positional arguments. The example binds 42 to a query parameter.

Dot case

/~billing.invoice.list

A namespaced symbolic destination. Dot-separated key tokens stay distinct from argument values.

Intent case

/~search;q.routing;page.2

Named values make bindings explicit. Unknown argument behavior is an application choice.

From anchor text to a route record

  1. Parse

    Normalize the input and identify a page, positional, dot, or named-argument instruction.

  2. Validate

    Check registered destinations, required arguments, argument limits and unknown named values.

  3. Resolve

    Bind params, query values and a hash. Pass the result to your framework’s router after your application’s checks.

A route registry is not an authorization policy. Permission metadata does not enforce permissions. Validate access independently, and keep sensitive route mappings private.

Inspect the actual SDK

A small fixed registry makes parsing and binding visible. This is an experiment, not an application router.

Local SDK experiment · no navigation

Use one of the four examples, or type your own. Parsing and resolution run locally; the input is never fetched or submitted.

Resolved against the example registry.

Parsed instruction

{
  "mode": "intent",
  "raw": "/~search;q.routing;page.2",
  "key": "search",
  "pathTokens": [
    "search"
  ],
  "namedArgs": {
    "q": "routing",
    "page": "2"
  }
}

Serialized anchor

/~search;q.routing;page.2

Validation result

{
  "valid": true,
  "instruction": {
    "mode": "intent",
    "raw": "/~search;q.routing;page.2",
    "key": "search",
    "pathTokens": [
      "search"
    ],
    "namedArgs": {
      "q": "routing",
      "page": "2"
    }
  },
  "errors": []
}

Resolved route record

{
  "success": true,
  "mode": "intent",
  "raw": "/~search;q.routing;page.2",
  "name": "Search",
  "path": "/search",
  "query": {
    "q": "routing",
    "page": "2"
  },
  "meta": {
    "key": "search",
    "namedArgs": {
      "q": "routing",
      "page": "2"
    },
    "instruction": {
      "mode": "intent",
      "raw": "/~search;q.routing;page.2",
      "key": "search",
      "pathTokens": [
        "search"
      ],
      "namedArgs": {
        "q": "routing",
        "page": "2"
      }
    }
  }
}
Inspect the fixed example registry
{
  "pages": {
    "settings": {
      "security": {
        "name": "Settings",
        "path": "/settings",
        "hash": "#security"
      }
    }
  },
  "global": {
    "profile": {
      "name": "Profile",
      "path": "/profile",
      "positionalBind": {
        "id": 0
      },
      "bindingTargets": {
        "id": "query"
      },
      "requiredPositionalCount": 1
    },
    "billing.invoice.list": {
      "name": "Invoices",
      "path": "/billing/invoices",
      "defaultQuery": {
        "view": "list"
      }
    },
    "search": {
      "name": "Search",
      "path": "/search",
      "namedBind": {
        "q": "q",
        "page": "page"
      },
      "bindingTargets": {
        "q": "query",
        "page": "query"
      },
      "requiredNamedArgs": [
        "q"
      ]
    }
  }
}

This bundle uses current repository core sources, including unpublished correctness fixes beyond npm core 0.2.0. It is not a new npm release. Result paths are examples; route records do not execute requests or grant authorization.

Use the core APIs

The parser can throw an AnchorRouteError. The validator and resolver return structured diagnostics. Builders handle escaping; do not concatenate untrusted arguments into route strings.

import { buildIntentAnchor, parseAnchor, validateAnchor, resolveAnchor }
  from '@nextera.one/anchor-routing-core';

const anchor = buildIntentAnchor('search', { q: 'route.registry', page: '2' });
// /~search;q.route%2Eregistry;page.2

const instruction = parseAnchor(anchor);
const check = validateAnchor(instruction, registry);
const result = resolveAnchor(instruction, registry);
// This example registry binds q and page into query values.
// Inspect result.success before handing it to a router.

Reserved dots, tildes and semicolons inside values must be percent-escaped. Serialization preserves named-argument insertion order; it does not promise alphabetic canonical ordering. A resolved path is not automatic interpolation of :params; adapters may need an explicit mapping.

Questions about the boundary

Does it replace Vue Router, React Router, or Framework7?

No. Anchor Routing adds symbolic parsing and resolution. Native routers continue to own browser history and navigation. Adapter bindings must match the installed framework and package versions.

Can a symbolic route identify a user or authorize an action?

A registry can bind values to a destination, but the result is navigation metadata. Keep authorization and ordinary resource identifiers in the application and its API contracts.

Is the discovery declaration a route registry?

No. The draft declaration describes supported grammar and discovery locations. It should not disclose private route mappings, permission rules, or hidden modules.

Which version does this site describe?

It describes the current repository and its unpublished patch sources, while listing published package versions separately. Core and adapters have their own versions. There is no new umbrella release or release date.

Does the playground send my input anywhere?

No. Parsing, declaration handling and route resolution use a locally bundled SDK with a fixed fictitious registry. No resolver server, analytics, CDN dependency, account or storage is used by the playground.