PermissionState ​

Reactive wrapper around the Permissions API. Queries the permission state for a given name and returns a signal that reactively tracks changes.

Loading demo...

Usage ​

angular-ts
import { Component } from '@angular/core';
import { permissionState } from '@signality/core';

@Component({
  template: `
    <p>Camera permission: {{ cameraPermission() }}</p>
  `,
})
export class PermissionDemo {
  readonly cameraPermission = permissionState('camera'); 
}

Parameters ​

ParameterTypeDescription
namePermissionNameThe permission name to query (e.g. 'camera', 'geolocation', 'notifications')
optionsPermissionStateOptionsOptional configuration (see Options below)

Options ​

The PermissionStateOptions extends Angular's CreateSignalOptions<PermissionState> and WithInjector:

OptionTypeDescription
equalValueEqualityFn<PermissionState>Custom equality function (see more)
debugNamestringDebug name for the signal (development only)
injectorInjectorOptional injector for DI context

Return Value ​

Returns a Signal<PermissionState> containing the current permission state:

  • 'granted' — The permission has been granted
  • 'denied' — The permission has been denied
  • 'prompt' — The user has not yet been asked (also used as default for SSR and unsupported browsers)

Examples ​

React to permission changes ​

angular-ts
import { Component, effect } from '@angular/core';
import { permissionState, geolocation } from '@signality/core';

@Component({
  template: `
    <p>Geolocation permission: {{ geoPermission() }}</p>
  `,
})
export class GeoPermissionTracker {
  readonly geoPermission = permissionState('geolocation');
  readonly geo = geolocation({ immediate: false });

  constructor() {
    effect(() => {
      if (this.geoPermission() === 'granted') {
        this.geo.start();
      }
    });
  }
}

Browser Compatibility ​

Not all browsers support querying all permission names. If the browser does not support querying a specific permission, the signal will remain at 'prompt'. See Permissions API browser compatibility on MDN for details.

SSR Compatibility ​

On the server, the signal initializes with 'prompt'.

Type Definitions ​

typescript
type PermissionStateOptions = CreateSignalOptions<PermissionState> & WithInjector;

function permissionState(
  name: PermissionName,
  options?: PermissionStateOptions,
): Signal<PermissionState>;
Edit this page on GitHub Last updated: Mar 19, 2026, 23:28:23