---
title: Binding
description: "The repository of a Repo Slot: `{ url, ref }`."
---

# `Binding`

Type, in `@jr2/orchestrator/src/parts.ts`. It is an export of `@jr2/orchestrator`, on the [Authoring surface](../authoring-surface.md) page, in Workspaces and Repos.

```ts
type Binding = {
  url: string;
  ref?: string;
};
```

The repository of a Repo Slot: `{ url, ref }`. `url` is the Repo's git url. `ref` is the branch
or commit that the branch Worktree starts from; absent, the Repo's default branch. Where only a
url is needed, a string is enough.

`workspace()` and `customize()` refuse:
- an empty `url`: ``<where>: Repo Slot "<slot>" is bound to an empty url (got <value>) — a slot
  is `open`, a url, `{ url, ref? }`, or a mapper `({ input }) => url | { url, ref? }` over the
  door (ADR-0051).``
- an empty `ref`: the same text, with `bound with an empty ref` in place of `bound to an empty
  url`.
- a url that names no Repo, such as a relative path: ``<where>: Repo Slot "<slot>" binds
  "<url>", which names no Repo — <reason> (ADR-0051).``

**Fields**

- `url`: `string`

  The Repo's git url.
- `ref` (optional): `string`

  The branch or commit that the branch Worktree starts from. Default: the Repo's default
  branch.

**Example**

```ts
import { jr2Setup, workspace, type Binding } from "@jr2/orchestrator";

const app: Binding = { url: "https://github.com/you/app.git", ref: "release-2" };

const body = jr2Setup().createMachine({
  id: "body",
  initial: "done",
  states: { done: { type: "final" } },
});

export const machine = workspace(body, {
  repos: { app },
  spec: () => ({ branch: "jr2/hotfix" }),
});
```

**See also**

- [Workspaces](../../concepts/workspaces.md)
- [ADR-0051: A Repo is a slot on the `workspace()` and a cache on the node](../decisions/0051-a-repo-is-a-slot-on-the-workspace-and-a-cache-on-the-node.md)
