# wrFeature

> Builds a `provideWr()` feature: what every `withX()` function returns. For a library that adds its own app-wide setting.

Source: https://ngwr.dev/reference/utils/wr-feature  
Kind: Util  
Added in v15  
Optional

## Usage

Name the feature and list what it provides. The app passes the result to `provideWr()` with the built-in features.

```angular-ts
import { InjectionToken } from '@angular/core';
import { type WrFeature, wrFeature } from 'ngwr/utils';

export interface MapsOptions {
  readonly tiles?: string;
}

export const MAPS_OPTIONS = new InjectionToken<MapsOptions>('MAPS_OPTIONS', {
  providedIn: 'root',
  factory: () => ({}),
});

export function withMaps(options: MapsOptions = {}): WrFeature<'maps'> {
  return wrFeature('maps', [{ provide: MAPS_OPTIONS, useValue: options }]);
}
```

```angular-ts
import { provideWr } from 'ngwr';
import { withDensity } from 'ngwr/density';

providers: [provideWr(withDensity({ defaultDensity: 'sm' }), withMaps({ tiles: '/tiles' }))],
```

| Argument | What it is |
| --- | --- |
| `kind` | The feature's name. In dev mode `provideWr()` throws when it gets the same kind twice, so pick one no other feature uses. |
| `providers` | What the feature registers. `provideWr()` flattens them into its own providers. |

- Give the token a root default, so the setting is optional.
- Annotate the return type as `WrFeature<'kind'>`. Do not read the object's members: they are private.

## API

| Name | Description | Type | Default |
| --- | --- | --- | --- |
| `wrFeature(kind, providers)` | Builds the feature `provideWr()` takes. | `<K extends string>(kind: K, providers: readonly (Provider \| EnvironmentProviders)[]) => WrFeature<K>` | `-` |
| `WrFeature<K>` | One piece of app-wide configuration. The return type of a `withX()` function. | `interface` | `-` |

## See also

- [Configuration](https://ngwr.dev/docs/configuration) — Set app-wide options at bootstrap.
- [withRenderOnNavigation](https://ngwr.dev/reference/utils/with-render-on-navigation) — A provideWr() feature for zoneless apps: a routed page is bound in the task that inserted it, so nothing fades in from browser defaults.
