> For the complete Lynkow documentation index in agent-friendly format, see [llms.txt](/llms.txt).

# PathsService

**Publié le** : 2026-08-20
**Catégorie** : Services

# PathsService

Service for URL path resolution and static site generation (SSG).

Accessible via `lynkow.paths`. Provides methods to list all available paths
for static generation, resolve a URL path to its content or category, and
check for configured redirects. Cached for 5 minutes (SHORT TTL).

Access via: `lynkow.paths`

## Methods

**4** methods

### `clearCache`

```typescript
clearCache(): void
```

Invalidates all cached path responses (list and resolve lookups).
Call this after knowing the site's URL structure has changed
(e.g. new content published, slugs updated) to force fresh data.

Returns: `void`

---

### `list`

```typescript
list(options?: BaseRequestOptions): Promise<PathsListResponse>
```

Retrieves all available URL paths for the site, intended for static site
generation (SSG). Returns every published content and category path with
segments, type, locale, and last modification date. Cached for 5 minutes
per locale.

| Parameter | Type | Description |
| --- | --- | --- |
| `options` | `BaseRequestOptions` | Request options; use `locale` to fetch paths for a specific locale only |


Returns: `Promise<PathsListResponse>`

```typescript
// In Next.js generateStaticParams()
export async function generateStaticParams() {
  const { paths } = await lynkow.paths.list()
  return paths.map(p => ({
    slug: p.segments
  }))
}
```

---

### `matchRedirect`

```typescript
matchRedirect(path: string, options?: BaseRequestOptions): Promise<Redirect | null>
```

Checks if a URL path has a configured server-side redirect. Returns the
redirect rule if one matches, or `null` if no redirect is configured.
This method is NOT cached to ensure redirect changes take effect immediately.
A 404 response from the API is treated as "no redirect found" (returns `null`).

| Parameter | Type | Description |
| --- | --- | --- |
| `path` | `string` | The URL path to check for redirects (e.g. `'/old-page'`, `'/legacy/url'`) |
| `options` | `BaseRequestOptions` | Request options (custom fetch options) |


Returns: `Promise<Redirect | null>`

```typescript
// In a Next.js middleware
const redirect = await lynkow.paths.matchRedirect(pathname)
if (redirect) {
  return NextResponse.redirect(redirect.target, redirect.statusCode)
}
// No redirect, continue to normal page rendering
```

---

### `resolve`

```typescript
resolve(path: string, options?: BaseRequestOptions): Promise<ResolveResponse>
```

Resolves a URL path to its corresponding content article or category.
Returns a discriminated union: check the `type` field to determine whether
the path matched a content (`'content'`) or a category (`'category'`).
Cached for 5 minutes per path+locale.

| Parameter | Type | Description |
| --- | --- | --- |
| `path` | `string` | The URL path to resolve (e.g. `'/blog/tech/my-article'`, `'/blog/tech'`) |
| `options` | `BaseRequestOptions` | Request options; use `locale` to resolve in a specific locale context |


Returns: `Promise<ResolveResponse>`

```typescript
const result = await lynkow.paths.resolve('/blog/tech/my-article')

if (result.type === 'content') {
  // Render the full article
  console.log(result.content.title)
} else if (result.type === 'category') {
  // Render the category listing page
  console.log(result.category.name)
  console.log(result.contents.data.length) // Articles in this category
}
```