Skip to content

alfredoperez/ngx-dev-toolbar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Angular Dev Toolbar

npm version Downloads License Angular GitHub Stars

A powerful development toolbar for Angular applications that helps developers to interact with the application in a more efficient way.

Dev Toolbar Demo

✨ Why ngx-dev-toolbar?

πŸš₯ Toggle feature flags without backend changes
🌍 Switch languages instantly
🧩 Test product features and subscription tiers
🎨 Switch themes on the fly
πŸ‘€ Change user sessions effortlessly
πŸ”„ Mock network requests in real-time
πŸ” Test permission-based UI without backend changes

No more context switching or backend dependencies - everything you need is right in your browser!

🎯 Features

πŸ“¦ Available Tools

  • Feature Flags
  • Language Switcher
  • Permissions Tool
  • App Features Tool
  • Presets Tool
  • Network Mocker (Request Interceptor)
  • Themes Coming Soon
  • User Session Coming Soon

πŸ› οΈ Extensible

  • Create custom tools
  • Add your own functionality

πŸ”’ Production Ready

  • Hidden by default in production
  • Zero production impact
  • Secure implementation

πŸ’Ύ Persistent State

  • Settings persist across reloads
  • Import/Export configuration

πŸ“± Quick Start

1. Installation
npm install ngx-dev-toolbar --save-dev
2. Import Component
import { DevToolbarComponent } from 'ngx-dev-toolbar';

@Component({
  imports: [DevToolbarComponent],
  template: ` <ndt-toolbar> </ndt-toolbar>`,
})
export class AppComponent {}

Available Tools

The tools come with a default implementation, but you can create your own tools and add them to the toolbar.

They have a service that you can use to interact with them.

Feature Flags

Configuration

In order to use the feature flags tool, you need to import the DevToolbarFeatureFlagService and inject it in your component.

Then you just need to call the setAvailableOptions method with the available feature flags that can come from your backend or a third party service.

import { DevToolbarFeatureFlagService } from 'ngx-dev-toolbar';
import { inject } from '@angular/core';

@Component({
  // ... component decorator
})
export class AppComponent {
  private featureFlagsService = inject(DevToolbarFeatureFlagService);

  constructor() {
    // Set available feature flags
    this.featureFlagsService.setAvailableOptions([
      { id: 'darkMode', name: 'Dark Mode' },
      { id: 'betaFeatures', name: 'Beta Features' },
      { id: 'experimentalUI', name: 'Experimental UI' },
    ]);
  }
}

Once it is added you should see them in the Feature Flags tool in the Angular Dev Toolbar with a visual filter indicator for easier navigation.

Note: Screenshots are being updated to reflect the latest UI improvements including new lock, filter, and bolt icons.

Usage

@Component({
  // ... component decorator
})
export class FeatureComponent {
  private featureFlagsService = inject(DevToolbarFeatureFlagService);

  ngOnInit() {
    this.featureFlagsService.getForcedValues().subscribe((forcedFlags) => {
      const isDarkMode = forcedFlags.some((flag) => flag.id === 'darkMode');
      // Apply dark mode logic
    });
  }
}

Recent UI Improvements

  • πŸ” Lock icon for permissions tool
  • πŸ” Filter icons for better visual clarity
  • ⚑ Bolt icon for custom tools
  • πŸ“ Improved text wrapping in tool descriptions

Permissions Tool

Configuration

import { DevToolbarPermissionsService } from 'ngx-dev-toolbar';
import { inject } from '@angular/core';

@Component({
  // ... component decorator
})
export class AppComponent {
  private permissionsService = inject(DevToolbarPermissionsService);

  constructor() {
    // Set available permissions
    this.permissionsService.setAvailableOptions([
      { id: 'can-edit', name: 'Can Edit Posts', description: 'Allows editing posts', isGranted: false, isForced: false },
      { id: 'can-delete', name: 'Can Delete Posts', description: 'Allows deleting posts', isGranted: false, isForced: false },
      { id: 'can-manage-users', name: 'Can Manage Users', description: 'Allows user management', isGranted: false, isForced: false },
      { id: 'is-admin', name: 'Admin Access', description: 'Full admin access', isGranted: false, isForced: false },
    ]);
  }
}

Usage

@Component({
  // ... component decorator
})
export class ProtectedComponent {
  private permissionsService = inject(DevToolbarPermissionsService);

  ngOnInit() {
    this.permissionsService.getForcedValues().subscribe((forcedPermissions) => {
      const canEdit = forcedPermissions.some(p => p.id === 'can-edit' && p.isGranted);
      const isAdmin = forcedPermissions.some(p => p.id === 'is-admin' && p.isGranted);
      // Apply permission-based logic
    });
  }
}

Language Switcher

Configuration

import { DevToolbarLanguageService } from 'ngx-dev-toolbar';
import { inject } from '@angular/core';

@Component({
  // ... component decorator
})
export class AppComponent {
  private languageService = inject(DevToolbarLanguageService);

  constructor() {
    // Set available languages
    this.languageService.setAvailableOptions([
      { code: 'en', name: 'English' },
      { code: 'es', name: 'Spanish' },
      { code: 'fr', name: 'French' },
    ]);
  }
}

Usage

@Component({
  // ... component decorator
})
export class TranslatedComponent {
  private languageService = inject(DevToolbarLanguageService);

  ngOnInit() {
    this.languageService.getForcedValues().subscribe(([selectedLang]) => {
      // Update component's language
      this.currentLanguage = selectedLang.code;
      this.loadTranslations();
    });
  }
}

App Features

The App Features tool allows you to test product-level feature availability like license tiers, deployment configurations, and environment flags without changing backend settings. Perfect for testing subscription tiers, premium features, and environment-specific functionality.

Configuration

import { DevToolbarAppFeaturesService, DevToolbarAppFeature } from 'ngx-dev-toolbar';
import { inject } from '@angular/core';

@Component({
  // ... component decorator
})
export class AppComponent {
  private appFeaturesService = inject(DevToolbarAppFeaturesService);

  constructor() {
    // Set available product features
    const features: DevToolbarAppFeature[] = [
      {
        id: 'advanced-analytics',
        name: 'Advanced Analytics Dashboard',
        description: 'Premium reporting and data visualization',
        isEnabled: false,  // Not available in current tier
        isForced: false
      },
      {
        id: 'multi-user-support',
        name: 'Multi-User Collaboration',
        description: 'Team features and user management',
        isEnabled: true,   // Available in current tier
        isForced: false
      },
      {
        id: 'white-label-branding',
        name: 'White Label Branding',
        description: 'Custom branding with your logo and colors',
        isEnabled: false,  // Enterprise feature
        isForced: false
      }
    ];

    this.appFeaturesService.setAvailableOptions(features);
  }
}

Usage

@Component({
  // ... component decorator
})
export class PremiumFeatureComponent {
  private appFeaturesService = inject(DevToolbarAppFeaturesService);

  ngOnInit() {
    this.appFeaturesService.getForcedValues().subscribe((forcedFeatures) => {
      // Apply forced feature states to your application
      forcedFeatures.forEach(feature => {
        if (feature.id === 'advanced-analytics' && feature.isEnabled) {
          this.enableAnalyticsDashboard();
        }
      });
    });
  }
}

Use Cases

  • SaaS Subscription Tiers: Test Basic, Professional, and Enterprise tiers without changing subscriptions
  • Feature Gating: Test premium feature access and upgrade flows
  • Environment Configuration: Test features specific to dev, staging, or production
  • License Management: Test on-premise vs cloud feature availability
  • A/B Testing: Test different feature combinations
  • Beta Rollouts: Enable/disable beta features for testing

Contributing

We welcome contributions! Please see our contributing guidelines for details.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

🌟 Stay Connected

LinkedIn Bluesky GitHub Stars


Built with ❀️ using Nx