> From the [Strife developer docs](https://strife.app/docs/reference/field-reference/fields.reference). Every page is listed in [llms.txt](https://strife.app/docs/llms.txt).

# fields.reference()

Deprecated: fields.related() replaces it in an upcoming release. Reference to other Strife documents, scoped by target type(s). Not localizable.

> [!WARNING]
> **Deprecated:** `fields.related()` replaces `fields.reference()` in an upcoming `@strifeapp/schema` release. Both map to the same editor (`str-related`), so you switch under the same key, and values already saved in the field keep working after the switch. Until that release, keep `fields.reference()`: it works in both the new and the classic interface, and you don't need to switch to [`fields.references()`](https://strife.app/docs/reference/field-reference/fields.references.md). From `@strifeapp/cli` 0.1.20, `strife push` and `strife typegen validate` refuse a schema with a `fields.reference()` field.

Reference to other Strife documents. Maps to editor `{ name: 'str-related', type: 'related' }`. Not localizable — the content index never treats relations as per-locale scalars.

Stored as an array of document ids or `{ id, displayName }` objects, and both are read: the new interface saves ids, and the classic interface saves `{ id, displayName }` copies. `Infer<>` gives `ContentRef[]`. At **read** time the content index projects each reference into the full target document, so [`strife typegen`](https://strife.app/docs/reference/cli/typegen.md) emits `Target[]` instead.

## Example

```ts
fields.reference({
  label: 'Author',
  to: 'author',
})

fields.reference({
  label: 'Related posts',
  to: ['article', 'video-post'],
  multiple: true,
})
```

## Options

| Option         | Type                          | Required | Description                                                                                                                                                                                                                                       |
| -------------- | ----------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `label`        | `string`                      | Yes      | Label shown to editors in Strife Studio.                                                                                                                                                                                                          |
| `to`           | `string \| readonly string[]` | Yes      | The `defineType` name(s) this reference may point to. Resolves to the editor's `allowedCollections` via the default collection rule (`toPlural(toPascalCase(name))`) and drives the generated read type (`Target[]`).                             |
| `propertyName` | `string`                      | No       | Override the stored property name.                                                                                                                                                                                                                |
| `multiple`     | `boolean`                     | No       | Allow selecting more than one document in the editor (wire `multiSelect`). **Defaults to `false`** — always compiled explicitly, so omitting it means single-select. Does not change the read type; the index always returns an array either way. |

> [!NOTE]
> **Studio-built templates are a separate concern.** `fields.reference()` always compiles an explicit `multiSelect: true/false`, so anything pushed through `defineType`/`strife push` is safe by default. A Related field built by hand in Strife Studio can still end up with no `multiSelect` attribute saved at all, in which case the `str-related` editor component's own default (`multiSelect = true`) applies — that's a separate frontend gap, not yet fixed, unrelated to this DSL.

> [!NOTE]
> If a target `defineType` overrides its own `collection`, the derived `allowedCollections` on this field (a picker-UI hint only) won't match it, and nothing warns about it. The generated read type is correct either way; only the Studio picker's collection scoping is affected.

## Output type

Write shape: `ContentRef[]` (`{ id, displayName? }`). Generated read shape (via `strife typegen`): `Target[]`, the fully projected target document(s).

## See also

* [Related](https://strife.app/docs/reference/fields/related.md) — the same editor, documented from the Strife Studio UI side.
* [`fields.references()`](https://strife.app/docs/reference/field-reference/fields.references.md) — a different editor (`str-references`): a sized list scoped by template name (`allow`) rather than by collection (`to`).
