---
title: "hostFeaturesFor(): function in Backends, TypeShade API"
description: "hostFeaturesFor, a function in Backends. Translate neutral capability ids into the feature strings one target's host has to activate before it creates a…"
url: https://typeshade.dev/api/hostfeaturesfor/
language: en
---

# `hostFeaturesFor()`

Function in Backends

Translate neutral capability ids into the feature strings one target's host has to activate before it creates a pipeline.

`import { hostFeaturesFor } from 'typeshade'`

The signature, the description and the examples come from the compiler's own source at commit af54ddad5.

## Syntax

```ts
function hostFeaturesFor(be: Backend, caps: readonly Capability[]): readonly string[]
```

## Parameters

**`be` `Backend`**

the backend whose capability profile does the translating.

**`caps` `readonly Capability[]`**

the neutral ids, usually `reflect(m).requiredFeatures`.

## Return value

`readonly string[]`

the host-side feature strings, in the order the ids arrived, with the id-less ones dropped.

## Description

On WebGL2 those are extension names for `gl.getExtension`, and on WebGPU they are feature names for `requestDevice({ requiredFeatures })`.

Feed it `reflect(m).requiredFeatures`, which reports the ids neutrally because reflection takes a module and never a backend.

It skips every id with no host half. A capability that is core on this target, or one the backend covers by emitting a source directive, contributes nothing. That is why this is a function: a `map` over the profile at each call site yields `undefined` holes a host then hands to `getExtension` verbatim. The returned list has no holes.

## Examples

### Example

```ts
import { hostFeaturesFor, reflect, glslEs300Backend, wgslBackend } from 'typeshade'

const caps = reflect(MODULE).requiredFeatures

for (const ext of hostFeaturesFor(glslEs300Backend, caps)) {
  if (!gl.getExtension(ext)) throw new Error(`WebGL2 lacks ${ext}`)
}

const device = await adapter.requestDevice({
  requiredFeatures: hostFeaturesFor(wgslBackend, caps),
})
```

## In the guide

- [Capabilities & extensions](https://typeshade.dev/guide/internals/capabilities-extensions/)

## See also

- [`reflect`](https://typeshade.dev/api/reflect/)
- [`capabilityMatrix`](https://typeshade.dev/api/capabilitymatrix/)

## Source

[`src/core/backend.ts`, line 125](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/backend.ts#L125), at commit af54ddad5
