[**Documentation**](../../../../README)

***

[Documentation](../../../../README) / [@zerotal/flow](../../README) / [index](../README) / url

# Function: url()

## Call Signature

> **url**(`value`, `context`): `void`

Defined in: [flow/src/decorators.ts:831](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/flow/src/decorators.ts#L831)

Syncs a field to the browser URL query string, so its value is reflected in and restored from
the URL.

### Parameters

#### value

`unknown`

#### context

`ClassFieldDecoratorContext`

### Returns

`void`

When configured, a field decorator; when used bare, nothing (applied directly).

### Remarks

Usable bare as `@url` (no parens) or configured as `@url({ as: 'page', history: 'push' })` — see
[UrlOptions](../interfaces/UrlOptions). By default the query parameter takes the property's name and updates
`replace` the current history entry.

A URL-synced field is client-visible by definition, so `@url` **implies `@expose`** — no need
to write both. Add `@locked` for a value the client reads but the server owns. Applies to a
field.

### Example

```tsx
class ProductList extends Component {
  @url page = 1;
  @url({ as: "q", history: "push" }) search = "";
}
```

## Call Signature

> **url**(`opts?`): `UrlDecorator`

Defined in: [flow/src/decorators.ts:832](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/flow/src/decorators.ts#L832)

Syncs a field to the browser URL query string, so its value is reflected in and restored from
the URL.

### Parameters

#### opts?

[`UrlOptions`](../interfaces/UrlOptions)

Optional [UrlOptions](../interfaces/UrlOptions) when called with parentheses.

### Returns

`UrlDecorator`

When configured, a field decorator; when used bare, nothing (applied directly).

### Remarks

Usable bare as `@url` (no parens) or configured as `@url({ as: 'page', history: 'push' })` — see
[UrlOptions](../interfaces/UrlOptions). By default the query parameter takes the property's name and updates
`replace` the current history entry.

A URL-synced field is client-visible by definition, so `@url` **implies `@expose`** — no need
to write both. Add `@locked` for a value the client reads but the server owns. Applies to a
field.

### Example

```tsx
class ProductList extends Component {
  @url page = 1;
  @url({ as: "q", history: "push" }) search = "";
}
```
