# Path Syntax

{% hint style="info" %}
*router5* uses [path-parser](https://github.com/troch/path-parser) for parsing, matching and generating URLs
{% endhint %}

## Defining parameters

Four parameter types are supported:

* `:param`: url parameters
* `;matrix`: matrix parameters
* `*splat`: for parameters spanning over multiple segments. Splat parameters are greedy and could swallow a

  large part of your URL. It is recommended to handle with care and to ONLY use on routes without children.
* `?param1&param2` or `?:param1&:param2`: query parameters

## Constrained parameters

Url and matrix parameters can be constrained with a regular expression. Backslashes need to be escaped.

* `:param<\\d+>` will match numbers only for parameter param
* `;id<[a-fA-F0-9]{8}>` will match 8 characters hexadecimal strings for parameter id

Constraints are also applied when building paths: when passing incorrect params to `.navigate()`, an error will be thrown.

## Absolute nested paths

You can define absolute nested paths (not concatenated with their parent's paths). Note that absolute paths are not allowed if any parent of a node has parameters.

```javascript
const router = createRouter([
    { name: 'admin', path: '/admin' },
    { name: 'admin.users', path: '~/users' }
]);

router.buildPath('admin.users'); // '/users'
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://router5.js.org/guides/path-syntax.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
