---
title: "Functions hooks"
description: "Hand-written hooks for `Function`. CRUD comes from `functions.gen.ts`;
this file adds the custom `invoke` op which the generator skips.

Mirror to docs/client-functions.md / Worker Loader pattern: `invokeFunction`
fires off the function as a Cloudflare Dynamic Worker and returns
`{ ok, result, error, durationMs }`."
section: "Libraries"
group: "React hooks"
order: 423
---

## Hooks

### `useCreateFunction` `mutation`

Create a function.

```ts
useCreateFunction(options?: MutationOpts<Function, CreateFunctionParams>)
```

**Types:** [Function](/types/function) · [CreateFunctionParams](/types/create-function-params)

### `useDeleteFunction` `mutation`

Soft-delete a function.

```ts
useDeleteFunction(options?: MutationOpts<SuccessResponse, string>)
```

**Types:** [SuccessResponse](/types/success-response)

### `useInvokeFunction` `composite`

Invoke a function. The runner loads the matching version's source
bundle into an isolate via the Worker Loader binding and returns the
function's JSON response.

```ts
useInvokeFunction(options?: MutationOpts<InvokeFunctionResponse, InvokeFunctionParams>)
```

**Types:** [InvokeFunctionResponse](/types/invoke-function-response) · [InvokeFunctionParams](/types/invoke-function-params)

### `useListFunctions` `query`

List functions.

```ts
useListFunctions(params?: Omit<ListFunctionsParams, | > & { filter?: FunctionFilter; orderBy?: FunctionOrderBy[]; } & FunctionShorthands, options?: QueryOpts<Page<Function>>)
```

**Types:** [ListFunctionsParams](/types/list-functions-params) · [FunctionFilter](/types/function-filter) · [FunctionOrderBy](/types/function-order-by) · [FunctionShorthands](/types/function-shorthands) · [Page](/types/page) · [Function](/types/function)

### `usePurgeFunction` `composite`

Permanently delete a soft-deleted function.

```ts
usePurgeFunction(options?: MutationOpts<SuccessResponse, PurgeFunctionParams>)
```

**Types:** [SuccessResponse](/types/success-response) · [PurgeFunctionParams](/types/purge-function-params)

### `useRestoreFunction` `composite`

Restore a soft-deleted function.

```ts
useRestoreFunction(options?: MutationOpts<Function, string>)
```

**Types:** [Function](/types/function)

### `useRetrieveFunction` `query`

Get a function by ID.

```ts
useRetrieveFunction(id: string, options?: QueryOpts<Function>)
```

**Types:** [Function](/types/function)

### `useUpdateFunction` `mutation`

Update a function.

```ts
useUpdateFunction(options?: MutationOpts<Function, UpdateFunctionParams>)
```

**Types:** [Function](/types/function) · [UpdateFunctionParams](/types/update-function-params)
