# useMachines

<!-- https://uncage.vercel.app/docs/api/react/functions/usemachines/ -->

```ts
function useMachines(opts?): object;
```

Defined in: react/src/hooks.ts:247

Connected mode: the signed-in user's computers on an Uncage hub. The first use probes the server
(`GET /machines`): a hub answers with the list (`connected`), a local daemon with 404 (`mode:
'local'`; everything else stays as in Local Mode). `selected` is the computer new sessions run
on; `current` is the one the open session runs on (`session.machineId`, set by the hub), else
`selected`. `watch` polls while mounted and the page is visible (`true` = every 3 s, or a number
of ms).

## Parameters

| Parameter | Type |
| ------ | ------ |
| `opts?` | \{ `watch?`: `number` \| `boolean`; \} |
| `opts.watch?` | `number` \| `boolean` |

## Returns

| Name | Type | Description | Defined in |
| ------ | ------ | ------ | ------ |
| `connected` | `boolean` | - | react/src/hooks.ts:249 |
| `current?` | `object` | The open session's computer (`session.machineId`), else `selected`; absent if not listed. | react/src/hooks.ts:253 |
| `current.agentOutdated` | `boolean` | - | protocol/dist/connected-DLqcTXoy.d.ts:1141 |
| `current.agentVersion` | `string` | - | protocol/dist/connected-DLqcTXoy.d.ts:1069 |
| `current.id` | `string` | - | protocol/dist/connected-DLqcTXoy.d.ts:1066 |
| `current.lastSeenAt` | `string` | - | protocol/dist/connected-DLqcTXoy.d.ts:1140 |
| `current.name` | `string` | - | protocol/dist/connected-DLqcTXoy.d.ts:1067 |
| `current.online` | `boolean` | - | protocol/dist/connected-DLqcTXoy.d.ts:1139 |
| `current.os` | `string` | - | protocol/dist/connected-DLqcTXoy.d.ts:1068 |
| `current.runtimes` | `object`[] | - | protocol/dist/connected-DLqcTXoy.d.ts:1070 |
| `current.transport` | `"ws"` \| `"http"` \| `null` | - | protocol/dist/connected-DLqcTXoy.d.ts:1142 |
| `currentId?` | `string` | Id of `current`, also when that computer is no longer listed (e.g. disconnected). | react/src/hooks.ts:255 |
| `error?` | `UncageClientError` | - | react/src/hooks.ts:257 |
| `install?` | [`InstallInfo`](https://uncage.vercel.app/docs/api/react/interfaces/installinfo.md) | - | react/src/hooks.ts:258 |
| `loading` | `boolean` | - | react/src/hooks.ts:256 |
| `machines` | `object`[] | - | react/src/hooks.ts:250 |
| `mode` | `"unknown"` \| `"local"` \| `"connected"` | - | react/src/hooks.ts:248 |
| `selected?` | `object` | - | react/src/hooks.ts:251 |
| `selected.agentOutdated` | `boolean` | - | protocol/dist/connected-DLqcTXoy.d.ts:1141 |
| `selected.agentVersion` | `string` | - | protocol/dist/connected-DLqcTXoy.d.ts:1069 |
| `selected.id` | `string` | - | protocol/dist/connected-DLqcTXoy.d.ts:1066 |
| `selected.lastSeenAt` | `string` | - | protocol/dist/connected-DLqcTXoy.d.ts:1140 |
| `selected.name` | `string` | - | protocol/dist/connected-DLqcTXoy.d.ts:1067 |
| `selected.online` | `boolean` | - | protocol/dist/connected-DLqcTXoy.d.ts:1139 |
| `selected.os` | `string` | - | protocol/dist/connected-DLqcTXoy.d.ts:1068 |
| `selected.runtimes` | `object`[] | - | protocol/dist/connected-DLqcTXoy.d.ts:1070 |
| `selected.transport` | `"ws"` \| `"http"` \| `null` | - | protocol/dist/connected-DLqcTXoy.d.ts:1142 |
| `loadInstallInfo()` | () => `Promise`\<`boolean`\> | - | react/src/hooks.ts:262 |
| `refresh()` | () => `Promise`\<`void`\> | - | react/src/hooks.ts:260 |
| `revoke()` | (`id`) => `Promise`\<`boolean`\> | - | react/src/hooks.ts:261 |
| `select()` | (`id`) => `void` | - | react/src/hooks.ts:259 |
