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

# BlocksService

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

# BlocksService

Service for retrieving global site blocks (header, footer, navigation, etc.).

Accessible via `lynkow.globals` (aliased from `lynkow.blocks`). Global blocks
are reusable, schema-driven content components shared across all pages of the
site. They are resolved server-side with DataSources. Responses are cached for
10 minutes (MEDIUM TTL) since global blocks change infrequently.

Access via: `lynkow.blocks`

## Methods

**4** methods

### `clearCache`

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

Invalidate every cached global block response (site config payload
and per-slug lookups). Call after an admin mutation or on receipt of
a `globalBlock.updated` webhook so the next public request hits the
origin and re-resolves any referenced variables.

Returns: `void`

```typescript
lynkow.globals.clearCache()
```

---

### `getBySlug`

```typescript
getBySlug(slug: string, options?: BaseRequestOptions): Promise<GlobalBlockResponse>
```

Retrieves a single global block by its slug, with fully resolved DataSource
data. Use this when you only need one specific block rather than all globals.
Cached for 10 minutes per slug+locale.

| Parameter | Type | Description |
| --- | --- | --- |
| `slug` | `string` | The unique slug of the global block (e.g. `'header'`, `'footer'`, `'nav'`, `'sidebar'`) |
| `options` | `BaseRequestOptions` | Request options; use `locale` to fetch a localized version |


Returns: `Promise<GlobalBlockResponse>`

```typescript
const { data } = await lynkow.globals.getBySlug('header')
console.log(data.name)  // "Header"
console.log(data.data)  // Resolved content (links, logo, menu items, etc.)
```

---

### `global`

```typescript
global(slug: string, options?: BaseRequestOptions): Promise<GlobalBlockResponse>
```

Retrieves a single global block by slug.

| Parameter | Type | Description |
| --- | --- | --- |
| `slug` | `string` | The block slug |
| `options` | `BaseRequestOptions` | Request options |


Returns: `Promise<GlobalBlockResponse>`

```typescript
// Deprecated -- use getBySlug() instead:
const { data } = await lynkow.globals.getBySlug('footer')
```

---

### `siteConfig`

```typescript
siteConfig(options?: BaseRequestOptions): Promise<SiteConfigResponse>
```

Retrieves the complete site configuration including basic site info
(name, domain, logo, favicon) and all global blocks resolved in a
single request. This is the recommended way to fetch layout data for
your site shell (header, footer, navigation). Cached for 10 minutes per locale.

| Parameter | Type | Description |
| --- | --- | --- |
| `options` | `BaseRequestOptions` | Request options; use `locale` to fetch localized block data |


Returns: `Promise<SiteConfigResponse>`

```typescript
const { data } = await lynkow.globals.siteConfig()
console.log(data.site.name)          // "My Site"
const header = data.globals['header'] // Resolved header block data
const footer = data.globals['footer'] // Resolved footer block data
```