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

***

[Documentation](../../../README) / [@zerotal/inertia](../README) / share

# Function: share()

## Call Signature

> **share**(`key`, `value`): `void`

Defined in: [inertia/src/share.ts:42](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/inertia/src/share.ts#L42)

Register shared prop(s) that Zerotal includes on **every** Inertia page, so page
components can read them without each controller passing them explicitly.

### Parameters

#### key

`string`

The shared prop name (single-key overload) — or, in the object overload, the map of names to values.

#### value

`unknown`

The value for `key` (single-key overload only); a plain value, a per-request factory, or a prop wrapper.

### Returns

`void`

### Remarks

Call once at boot (typically in a service provider) — a later `share()` of the
same key overwrites the previous value. Values may be plain data, a factory
function (re-evaluated lazily per request, e.g. to read the current user), or a
prop wrapper. The built-in shared keys (`auth`, `flash`, `errors`, `old`) are
always present in addition to whatever you register here; see sharedProps.

Two call styles: a single `key`/`value` pair, or an object of many at once.

### Example

```ts
// In a service provider's boot() — available on every page (auth/flash/errors/old
// are already built in; register your own extras here).
Inertia.share({
  appName: 'Acme',
  permissions: () => Auth.user()?.permissions ?? [],  // factory re-runs each request
});

// Or a single key:
Inertia.share('year', () => new Date().getFullYear());
```

## Call Signature

> **share**(`values`): `void`

Defined in: [inertia/src/share.ts:43](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/inertia/src/share.ts#L43)

Register shared prop(s) that Zerotal includes on **every** Inertia page, so page
components can read them without each controller passing them explicitly.

### Parameters

#### values

`Record`\<`string`, `unknown`\>

### Returns

`void`

### Remarks

Call once at boot (typically in a service provider) — a later `share()` of the
same key overwrites the previous value. Values may be plain data, a factory
function (re-evaluated lazily per request, e.g. to read the current user), or a
prop wrapper. The built-in shared keys (`auth`, `flash`, `errors`, `old`) are
always present in addition to whatever you register here; see sharedProps.

Two call styles: a single `key`/`value` pair, or an object of many at once.

### Example

```ts
// In a service provider's boot() — available on every page (auth/flash/errors/old
// are already built in; register your own extras here).
Inertia.share({
  appName: 'Acme',
  permissions: () => Auth.user()?.permissions ?? [],  // factory re-runs each request
});

// Or a single key:
Inertia.share('year', () => new Date().getFullYear());
```
