> Documentation index: https://www.gooddata.ai/docs/gooddata-ui/llms.txt lists every page of these docs as Markdown.

# useBackend()

- Package: [@gooddata/sdk-ui](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/index.md)
- Kind: function
- Source: https://github.com/gooddata/gooddata-ui-sdk/blob/rel/11.64/libs/sdk-ui/src/base/react/BackendContext.tsx
- Guides: [useBackend](https://www.gooddata.ai/docs/gooddata-ui/latest/integrations/hooks/use-backend/index.md)

Hook to get analytical backend instance provided to [BackendProvider()](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.backendprovider/index.md).

**Signature:**

```typescript
useBackend: (backend?: IAnalyticalBackend) => IAnalyticalBackend | undefined
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| backend | [IAnalyticalBackend](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ianalyticalbackend/index.md) | _(Optional)_ backend to use instead of context value. If undefined, the context value is used. |

**Returns:**

[IAnalyticalBackend](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.ianalyticalbackend/index.md) &#124; undefined

## Remarks

You can set a backend override that will be returned if defined. This makes the usage more ergonomic (see the following example).

Note: For a better TypeScript experience without the hassle of undefined values, you can use the [useBackendStrict()](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui/sdk-ui.usebackendstrict/index.md) hook.

## Example

```tsx
// instead of
const fromContext = useBackend();
const effectiveBackend = fromArguments ?? fromContext.
// you can write
const backend = useBackend(fromArguments);
```
